Linking against older libraries

Discussion in 'Mac Programming' started by rinseout, Jul 5, 2005.

  1. rinseout macrumors regular

    Joined:
    Jan 20, 2004
    #1
    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.)
     
  2. rinseout thread starter macrumors regular

    Joined:
    Jan 20, 2004
    #2
    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.
     

Share This Page