public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: Question about linking multiple copies of the same library
@ 2004-12-31  8:38 Lourens Janse van Rensburg
  2004-12-31 15:32 ` Matthias David Siebler
  0 siblings, 1 reply; 4+ messages in thread
From: Lourens Janse van Rensburg @ 2004-12-31  8:38 UTC (permalink / raw)
  To: msiebler, gcc-help


What I usually do is to make a symbolic link that has the name of the
desired (older) version of the .so, and make it point to the current
(newer) version of the .so

e.g. if I have a program that requires an older version of library x,
say libx.so.1, while I have on my system only a newer version, say
libx.so.2, I do the following:

$ll
-rw-rw-rw-    1 vanrensb users        0 Dec 31 10:24 libX.so.2

$ln -s libx.so.2 libx.so.1

$ll
-rw-rw-rw-    1 vanrensb users        0 Dec 31 10:24 libx.so.2
lrwxrwxrwx    1 vanrensb users        9 Dec 31 10:26 libx.so.1 ->
libx.so.2


This usually works because the libraries are backwards compatible, i.e.
they add new stuff in the later versions but they don't remove the
existing functions inside the library.  

* Your old program should run OK because the symlink makes it think that
it is linking to the older version of the .so.
* Your new programs should automatically link to the current (newer)
version of the .so because your compiler/linker is aware of the correct
library version that it needs.

Hope this helps.

Lourens...


-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Matthias David Siebler
Sent: 30 December 2004 01:19
To: gcc-help@gcc.gnu.org
Subject: Question about linking multiple copies of the same library



Hello:

i have a question about how to link multiple copies of the same library.
I have a existing application with needs to include a thirdparty
library.  (For this library source is not
available)  This is a dynamically linked library that requires
libstdc++-libc6.1-2.so.3

My current application uses a newer compiler which requires
libstdc++-libc6.2-2.so.3

Is it possible to link the application such that the IBM library links
to the old libstdc++ and everything else resolves to the new library?

How can this be done?

Thanks



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Question about linking multiple copies of the same library
  2004-12-31  8:38 Question about linking multiple copies of the same library Lourens Janse van Rensburg
@ 2004-12-31 15:32 ` Matthias David Siebler
  2005-01-07 22:25   ` Craig Allen
  0 siblings, 1 reply; 4+ messages in thread
From: Matthias David Siebler @ 2004-12-31 15:32 UTC (permalink / raw)
  To: Lourens Janse van Rensburg; +Cc: gcc-help



> 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.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Question about linking multiple copies of the same library
  2004-12-31 15:32 ` Matthias David Siebler
@ 2005-01-07 22:25   ` Craig Allen
  0 siblings, 0 replies; 4+ messages in thread
From: Craig Allen @ 2005-01-07 22:25 UTC (permalink / raw)
  Cc: gcc-help

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Question about linking multiple copies of the same library
@ 2004-12-29 23:19 Matthias David Siebler
  0 siblings, 0 replies; 4+ messages in thread
From: Matthias David Siebler @ 2004-12-29 23:19 UTC (permalink / raw)
  To: gcc-help



Hello:

i have a question about how to link multiple
copies of the same library.  I have a existing
application with needs to include a thirdparty
library.  (For this library source is not
available)  This is a dynamically linked library
that requires libstdc++-libc6.1-2.so.3

My current application uses a newer compiler
which requires libstdc++-libc6.2-2.so.3

Is it possible to link the application such that
the IBM library links to the old libstdc++ and
everything else resolves to the new library?

How can this be done?

Thanks



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-01-07 22:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-31  8:38 Question about linking multiple copies of the same library Lourens Janse van Rensburg
2004-12-31 15:32 ` Matthias David Siebler
2005-01-07 22:25   ` Craig Allen
  -- strict thread matches above, loose matches on Subject: below --
2004-12-29 23:19 Matthias David Siebler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).