tags:

views:

864

answers:

3

I'm building a shared library with g++ 3.3.4. I cannot link to the library because I am getting

./BcdFile.RHEL70.so: undefined symbol: _ZNSt8_Rb_treeIjjSt9_IdentityIjESt4lessIjESaIjEE13insert_uniqueERKj

Which c++filt describes as

std::_Rb_tree<unsigned int, unsigned int, std::_Identity<unsigned int>, std::less<unsigned int>, std::allocator<unsigned int> >::insert_unique(unsigned int const&)

I thought this might have come from using hash_map, but I've taken that all out and switched to regular std::map. I am using g++ to do the linking, which is including -lstdc++.

Does anyone know what class would be instantiating this template? Or even better, which library I need to be linking to?

EDIT: After further review, it appears adding the -frepo flag when compiling has caused this, unfortunately that flag is working around gcc3.3 bug.

+1  A: 

std::_Rb_Tree might be a red-black tree, which would most likely be from using map. It should be part of libstdc++, unless your library is linking against a different version of libstdc++ than the application, which from what you've said so far seems unlikely.

EDIT: Just to clarify, the red-black tree is the underlying data structure in map. All that hash_map does is hash the key before using it, rather than using the raw value.

Branan
A: 

Try

#include < map > 
in the source file where you are using map.

Dima
A missing #include would cause a compile time error, not a link time error.
KeithB
I had a very similar error once. Adding #include < map >, even though it was a part of another include, fixed it. I never figured out what it was. Must have been a problem with instantiation of std::map. In general you're right. But with templates, you can get all sorts of weird errors.
Dima
Bumped back up. Could indeed be the problem, as <map> and <set> usually include other headers. std::map<> might very well be declared in a base header shared with <set>, then defined in <map>. So, you'd get only std::map declarations if you'd include just <set>. (Could - depends on compiler)
MSalters
A: 

You seem to have 2 different incompatible versions of libstdc++.so from different versions of gcc. Check your paths.