NEWBIE: cout<< problem

Pieter Thysebaert pieter.thysebaert@intec.rug.ac.be
Mon May 5 07:22:00 GMT 2003


On Monday 05 May 2003 08:59, Arash Bijanzadeh wrote:
> Still same problem, se below my hello.cpp and the gcc error message:
>
> ab@gorg:~/cpptut$ cat hello.cpp
> #include <iostream>
>
> using namespace std;
> int main(void) {
>           cout<<"Hello world"<<endl;
>             return 0;
> }
> ab@gorg:~/cpptut$ gcc -o hello hello.cpp
> /tmp/ccNKWoGc.o: In function `main':
> /tmp/ccNKWoGc.o(.text+0xa): undefined reference to `endl(ostream &)'
> /tmp/ccNKWoGc.o(.text+0x17): undefined reference to `cout'
> /tmp/ccNKWoGc.o(.text+0x1c): undefined reference to
> `ostream::operator<<(char const *)'
> /tmp/ccNKWoGc.o(.text+0x27): undefined reference to
> `ostream::operator<<(ostream &(*)(ostream &))'
> collect2: ld returned 1 exit status
>

Since it's a C++ program:
try "g++ -o hello hello.cpp" or "gcc -o hello hello.cpp -lstdc++"

Pieter



More information about the Gcc-help mailing list