Skip to content

June 7, 2012

C Plus Plus Error: undefined reference to `std::basic_string, std::allocator >::basic_string()’

by noise

Score.cc:(.text+0x11): undefined reference to `std::basic_string, std::allocator >::basic_string()’
Score.cc:(.text+0x2a): undefined reference to `std::string::operator=(char const*)’
Score.cc:(.text+0x5d): undefined reference to `std::basic_string, std::allocator >::~basic_string()’
Score.cc:(.text+0x82): undefined reference to `std::terminate()’
/tmp/Score-AOj1oH.o: In function `Score::~Score()':
Score.cc:(.text+0xb1): undefined reference to `std::basic_string, std::allocator >::~basic_string()’
/tmp/Score-AOj1oH.o: In function `Score::GetPlayerName()':
Score.cc:(.text+0xe8): undefined reference to `std::basic_string, std::allocator >::basic_string(std::string const&)’
/tmp/Score-AOj1oH.o:(.eh_frame+0x13): undefined reference to `__gxx_personality_v0′
clang: error: linker command failed with exit code 1 (use -v to see invocation)

To solve this error compile using -lstdc++ option (which links to stdc++ library):

clang -lstdc++ Score.cc main.cc

or:

g++ -lstdc++ Score.cc main.cc

Read more from C and C++ Errors

Leave a Reply

required
required

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments