Bug 44092 - Undefined Symbol: std::basic_string
Summary: Undefined Symbol: std::basic_string
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: link-failure
Depends on:
Blocks:
 
Reported: 2010-05-12 09:11 UTC by Stefan Winter
Modified: 2010-09-29 15:12 UTC (History)
2 users (show)

See Also:
Host: IBM PowerPC / AIX 5.3
Target:
Build: gcc 4.0.0-1
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Winter 2010-05-12 09:11:03 UTC
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.
Comment 1 Paolo Carlini 2010-05-12 09:31:46 UTC
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...
Comment 2 Richard Biener 2010-05-12 10:34:22 UTC
And neither 4.0.0 nor 4.2.x are maintained anymore nor do you provide a
testcase to verify your failure.
Comment 3 Stefan Winter 2010-05-14 10:04:04 UTC
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);
}

Comment 4 Paolo Carlini 2010-05-14 10:27:43 UTC
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.
Comment 5 Stefan Winter 2010-05-14 11:55:36 UTC
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.
Comment 6 Jonathan Wakely 2010-05-14 12:05:32 UTC
You might want to read http://gcc.gnu.org/install/ starting with "Prerequisites"