« Return to Thread: ERROR Undefined symbol basic_ostream

ERROR Undefined symbol basic_ostream

by mavin :: Rate this Message:

Reply to Author | View in Thread

I can compile a hello world program.
$> cat hello.cc
#include <iostream>

int main(int argc, char *argv[])
{
  printf("Hello, world!\n");
  std::cout << "Hello, world!\n";
}

$> g++ -c hello.cc

$> ls -l hello.o
-rw-r--r-- 1 xxxxxxxx xxxxxxx 2528 11 Dec 12:23 hello.o

I can't link the hello world program.

$> g++ -o hello hello.o

throws me this error,

ld: 0711-317 ERROR: Undefined symbol: .std::basic_ostream<char, std::char_traits<char> >& std::opera
tor<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: ld returned 8 exit status

I am using following gcc version,

gcc version 4.0.0

For everyones information, I do have libstdc++.a present in my system and I even tried building linking the library as,

$> g++ -o hello hello.o -L/usr/lib -lstdc++

but eventually it gives me the same error.

Help from anyone would be appreciated.

 « Return to Thread: ERROR Undefined symbol basic_ostream