Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

rinseout

macrumors regular
Original poster
Jan 20, 2004
160
0
Say I have some guy's library (.a) which was compiled using g++-3.3. I have code that links against it, but I'd like to compile my code using g++-4, and use the version 4 linker. Is this allowed? If so, is stuff like this bound to happen and how do you avoid it?
Code:
/usr/bin/ld: Undefined symbols:
std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_empty_rep_storage
__ZNSt15basic_streambufIcSt11char_traitsIcEED4Ev
__ZNSt15basic_streambufIcSt11char_traitsIcEEC4Ev
std::__default_alloc_template<true, 0>::deallocate(void*, unsigned long)
std::__default_alloc_template<true, 0>::allocate(unsigned long)
collect2: ld returned 1 exit status
I get a clean compile if I uses 3.3 for everything, but if I use the guy's library (which is kind of crappy and not easily compilable under g++-4) then I get the above kind of thing during linkage. (It could also be that the linking trouble is related to my code (some use of templates, for instance), which is the other thing I'm trying to sort out.)
 

rinseout

macrumors regular
Original poster
Jan 20, 2004
160
0
I'll answer my own question (I think): you cannot reliably do this. There have been enough changes between 3.3 and 4.0 that the binaries are not compatible.
In particular, in 3.3 there is a symbol std::__default_alloc_template which did not make it into 4.0, so the linking will fail.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.