Question about linking multiple copies of the same library

Craig Allen callen@gemini.edu
Fri Jan 7 22:25:00 GMT 2005


Matthias,

I'm not sure this is what you want to hear... someone might know a 
better hack that will work for you... but I think you have a serious 
issue there in that a regular linker is not going to like the idea that 
you want identical symbols linked for  different compilation units.

If you used static libraries, you could do this by being careful with 
intermediate linking steps where you linked the libraries into the 
different modules and then linked everything together in the end.  I 
actually suspect you would get some duplicate symbol errors in that case 
too.

With .so files you can dlopen() the library yourself and make the 
symbolic links dynamically.  This is a pain, yes?  In fact, you can't do 
this for a precompiled thirdparty library and would have to, instead, 
either create a thunking library to do this for the thirdparty library, 
or in all your standard library use you would have to manage all the 
dynamic library loading for yourself in your main application.  Both are 
a mess.

I think the solution of least effort is to give up wanting to use the 
newer version of the standard library and just use the functions in the 
older library for your own code as well.  Ship that library or require 
your customer to aquire it on their own.

Hopefully someone will have something better than this. What I've said 
is from years of C++ programming, not gcc knowledge, so maybe someone 
knows some gcc-specific trick.  good luck.

-craig

Matthias David Siebler wrote:

>
>
>> This usually works because the libraries are backwards compatible,
>
>
>
>
> In general one would hope that to be true, but not in this case.  
> Allow me to be more specific:
>
> i am compiling on a GNU/Linux/Intel system.
>
> I have a thirdparty library (libthird.so) that requires 
> libstdc++-libc6.1-2.so.3
> if libthird.so is linked against another newer version of libstdc++ 
> then it will crash.
>
> However, i wish to link the rest of my application against a newer 
> version of libstdc++
>
> is this possible?  How do i set the options so that libthird.so 
> resolves only against libstdc++-lib6.1-2.so.3 and the rest of the code 
> links against the newest version of  libstdc++?
>
>
> Thanks to everyone for your help.
>
>
>
>


-- 
Craig Allen
callen@gemini.edu
Software Engineer



More information about the Gcc-help mailing list