problem when building a file

hello,
according to tutorial, my makefile looks like:

all: hello.exe
clean:
main.o:
qcc -c -o main.o main.cpp
hello.exe: main.o
qcc -o hello main.o

and the file main.cpp is :

#include

using namespace std;

int main () {

// Say Hello five times

for (int index = 0; index < 5; ++index)

cout << “HelloWorld!” << endl;

char input = ‘i’;

cout << “To exit, press ‘m’” << endl;

while(input != ‘m’) {

cin >> input;

cout << "You just entered " << input

<< " you need to enter m to exit." << endl;

}

exit(0);

}

So, when I build the project, there is a lot of errors like
"main.o(.text+0x29): undefined reference to `std::cout’ "

I don’t understand why such errors because there is the include file. Must I
specify this include file in th e makefile or the make command does it
itself??

It could seem easy to explain my error but I have no idea!

Thank you for your help!!!



cyril

cyril bros wrote:

hello,
according to tutorial, my makefile looks like:

all: hello.exe
clean:
main.o:
qcc -c -o main.o main.cpp
hello.exe: main.o
qcc -o hello main.o

Hello,

you must tell to linker, that you use C++, or to use QCC compiler

qcc -lang-c++ -o hello main.o
or
QCC -o hello main.o

Marian

and the file main.cpp is :

#include <iostream

using namespace std;

int main () {

// Say Hello five times

for (int index = 0; index < 5; ++index)

cout << “HelloWorld!” << endl;

char input = ‘i’;

cout << “To exit, press ‘m’” << endl;

while(input != ‘m’) {

cin >> input;

cout << "You just entered " << input

" you need to enter m to exit." << endl;

}

exit(0);

}

So, when I build the project, there is a lot of errors like
"main.o(.text+0x29): undefined reference to `std::cout’ "

I don’t understand why such errors because there is the include file. Must I
specify this include file in th e makefile or the make command does it
itself??

It could seem easy to explain my error but I have no idea!

Thank you for your help!!!



cyril


\