If I compile a short Programm with g++ and I declare a STL-String (only declare!), than it is ok ("g++ -c -Wall Progname.c"). But if I link the same programm with "g++ -o Progname Progname.o", than I get an linker error: ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits< char>, std::allocator<char> >::basic_string() ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits< char>, std::allocator<char> >::~basic_string() If I use some other STL-Funtions as e.g. "maps", "vectors", I get no errors. I also have tried the "gcc-4.2.0", but the same problem (as with -> "gcc 4.0.0"). Even a linker option "-lstdc++" does not help.
Something seems seriously broken in your setup, of course in a proper one this kind of problem would have blocked the release. Let's CC David...
And neither 4.0.0 nor 4.2.x are maintained anymore nor do you provide a testcase to verify your failure.
My sample program: // g++ 4.0.0-1 // compile: g++ -c -Wall progname.c -> ist ok // link (AIX linker "ld"): g++ -o progname progname.o // ERROR: Undefined symbol: .std::basic_string<char, std::char_traits< // char>, std::allocator<char> >::basic_string() // ERROR: Undefined symbol: .std::basic_string<char, std::char_traits< // char>, std::allocator<char> >::~basic_string() // #include <stdio.h> #include <string> using namespace std; //------------------------------------ main -------------------------------- // int main (int argc,char **argv) { string test; return(0); }
Yes. Note that gcc-4.0.x, 4.1.x, and 4.2.x are *not maintained anymore* and bugs affecting only those release series are simply closed. Thus, before anything else, try a current release, preferably gcc-4.4.x.
If I want to install the gcc-4.4.0, I get the error "libgmp.a" and libmpfr.a not found. It seems I have to rebuild something.
You might want to read http://gcc.gnu.org/install/ starting with "Prerequisites"