Undefined reference to `std::basic_string<char>... error

Hi Clang Developers,

I downloaded the latest revision (r123891) of LLVM via SVN and followed the instructions at http://clang.llvm.org/get_started.html to configure and build.

While building I received following error:

Linking Debug+Asserts executable FileCheck

/u/asudani/project/build/Debug+Asserts/lib/libLLVMSupport.a(Program.o): In function `char* std::basic_string<char, std::char_traits, std::allocator >::_S_construct<char const*>(char const*, char const*, std::allocator const&, std::forward_iterator_tag)':

/usr/software/lib/gcc/x86_64-unknown-linux-gnu/4.1.1/…/…/…/…/include/c++/4.1.1/bits/basic_string.tcc:158: undefined reference to `std::basic_string<char, std::char_traits, std::allocator >::_Rep::_M_set_length_and_sharable(unsigned long)

Searching for error directed me to forum suggesting addition of –lstdc++ linker option:http://www.codeguru.com/forum/archive/index.php/t-351875.html.

I tried to modify makefile but it didn’t worked. What is the best way to modify LDFLAGS for incorporating the specified option ?

After looking logs for past revisions, one of them (r121379) yielded:

r121379 | mspencer | 2010-12-09 23:06:48 +0530 (Thu, 09 Dec 2010) | 1 line

Support/MemoryBuffer: Replace all uses of std::string *ErrMsg with error_code &ec.

And fix clients.

I want to know if these observations are related in any way and if this is known error and has been encountered before by users.


Mohit Asudani