Hello,
I'm getting undefined references using gcc3.4 when linking a program against
one of my shared libraries:
.../libxeldaCommon_sd.so: undefined reference to `std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::_M_check(unsigned int)
const'
.../libxeldaCommon_sd.so: undefined reference to `std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::_Rep::_S_create(unsigned
int, std::allocator<char> const&)'
.../libxeldaCommon_sd.so: undefined reference to `std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::_S_empty_rep_storage'
.../libxeldaCommon_sd.so: undefined reference to
`std::__default_alloc_template<true, 0>::deallocate(void*, unsigned int)'
While I have no errors when I build the same libraries and programs with gcc
3.2 (same gcc 3.2 / gcc 3.4 command lines).
I guess these errors are related to template instantiations. If I'm not
mistaken I have three options for dealing with them:
- do nothing (i.e. no particular compile & link options for templates): this
is currently what I do. This works with gcc 3.2. I know this can lead with
code duplication, but I can leave with that for the moment (size of
libraries produced with gcc 3.2 remains correct)
- use -frepo option. I tried that, and had to do a strange two-steps link:
g++ -o /dev/null <object files> <linker options> > foo.log (many errors
but cause instantiations to be generated?)
then
g++ -shared -g -o <lib name> <object files> <linker options> (library
properly created)
Still, when I link the program against the produced library, I get the same
undefined references...
- use -frepo and -fno-implicit-templates: not tried yet (would prefer no to
write the explicit instantiations myself...)
Any suggestion?
I saw two messages referring to two of the symbols above, but without
solution:
http://gcc.gnu.org/ml/gcc-help/2005-05/msg00269.html and
http://gcc.gnu.org/ml/gcc-help/2005-05/msg00305.html
Many thanks for your help!
Best regards,
Yves