Unix Technical Forum

How to version shared libraries?

This is a discussion on How to version shared libraries? within the AIX Operating System forums, part of the Unix Operating Systems category; --> I am trying to figure out how to install more than one version of a shared library on an ...


Go Back   Unix Technical Forum > Unix Operating Systems > AIX Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-05-2008, 11:25 AM
Laurenz Albe
 
Posts: n/a
Default How to version shared libraries?

I am trying to figure out how to install more than one version of a
shared library on an AIX system at the same time.

Can you tell me if there is a canonical way to do this on AIX?

I am aware that I can put the libraries in different directories and
use LIBPATH, but is there a different way?

What I want to achieve is something similar to the following procedure
in Linux:

- At some time, version 4 of a shared library (= shared object on Linux)
is installed:
- libpq.so.4 is created with the linker. It is given the SONAME
(shared object name) 'libpq.so.4'.
- libpq.so.4 is copied to /usr/lib
- A symbolic link libpq.so pointing to libpq.so.4 is added to /usr/lib
- Now, when an executable is dynamically linked with -lpq, the
linker finds libpq.so and adds a reference to the SONAME libpq.so.4
to the loader section of the resulting executable.
- Some time later, version 5 of the shared library is installed,
it is called libpq.so.5, and the symbolic link libpq.so is made to
point at the new library.
- Any executable linked with -lpq after that will reference libpq.so.5,
but the executable that was linked earlier still points to the old
version of the library and will continue to work.


Here is an idea I have - I'd like to hear your opinion on it and would
be grateful if somebody has a better idea.

- First I create the shared object libpq.so.4 and create a library with
ar -cr /usr/lib/libpq.a libpq.so.4
- Executables dynamically linked with -lpq will reference
libpq.a(libpq.so.4).
- Now I create the shared object libpq.so.5 and add it to the shared
library libpq.a with
ar -ct /usr/lib/libpq.a libpq.so.5
- As ar adds the object at the end of the library (is there a way to
tell ar that it should add the object at the beginning??), I'll have to
ar -m -b libpq.so.4 libpq.a libpq.so.5
- An executable that is linked with -lpq now will reference
libpq.a(libpq.so.5), but the old executable will still work.

This procedure still looks somewhat flaky to me, particularly the fact that
I have to jiggle the order of the shared objects in the library to make it
work. I'd like a procedure to install version 5 of the shared library
that works, regardless if a previous version of the library is already
installed or not.

Yours,
Laurenz Albe
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-05-2008, 11:26 AM
Paul Pluzhnikov
 
Posts: n/a
Default Re: How to version shared libraries?

Laurenz Albe <invite@spam.to.invalid> writes:

> Here is an idea I have - I'd like to hear your opinion on it and would
> be grateful if somebody has a better idea.


That is essentially what IBM uses:

$ ar tv /lib/libpthreads.a
r--r--r-- 2/2 267250 Aug 03 19:08 2004 shr.o # old "draft 7" threads
r--r--r-- 2/2 22535 Aug 03 19:08 2004 shr_comm.o
r--r--r-- 2/2 280585 Aug 03 19:08 2004 shr_xpg5.o # new "standard" threads.
rw-r----- 300/1 1486 Jun 06 11:21 2001 init.o

> - First I create the shared object libpq.so.4 and create a library with
> ar -cr /usr/lib/libpq.a libpq.so.4
> - Executables dynamically linked with -lpq will reference
> libpq.a(libpq.so.4).
> - Now I create the shared object libpq.so.5 and add it to the shared
> library libpq.a with
> ar -ct /usr/lib/libpq.a libpq.so.5


You do one more thing: you mark libpq.so.4 with a F_LOADONLY flag.
After that, libpq.so.4 will load for any binary that has requested
it, but will not be available for (static) linking.

> - As ar adds the object at the end of the library (is there a way to
> tell ar that it should add the object at the beginning??), I'll have to
> ar -m -b libpq.so.4 libpq.a libpq.so.5


The order doesn't matter after you've marked all but the most
current library with F_LOADONLY.

Gary Hook provided a way to turn F_LOADONLY on/off:

> I think there's a strip option in 4.3.3 that allows you
> to set/unset the LOADONLY bit (dump -ov /usr/lib/libpthreads.a and look
> at shr.o). Try -e/-E.


His original message seem to have disappeared from google, but my
followup is still there:
http://groups.google.com/group/comp....d37c872c3e92f3

See also:
http://groups.google.com/group/comp....7425d7ddf12114

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-05-2008, 11:26 AM
Laurenz Albe
 
Posts: n/a
Default Re: How to version shared libraries?

Paul Pluzhnikov <ppluzhnikov-nsp@charter.net> wrote:
>> - First I create the shared object libpq.so.4 and create a library with
>> ar -cr /usr/lib/libpq.a libpq.so.4
>> - Executables dynamically linked with -lpq will reference
>> libpq.a(libpq.so.4).
>> - Now I create the shared object libpq.so.5 and add it to the shared
>> library libpq.a with
>> ar -ct /usr/lib/libpq.a libpq.so.5

>
> You do one more thing: you mark libpq.so.4 with a F_LOADONLY flag.
> After that, libpq.so.4 will load for any binary that has requested
> it, but will not be available for (static) linking.
>
>> - As ar adds the object at the end of the library (is there a way to
>> tell ar that it should add the object at the beginning??), I'll have to
>> ar -m -b libpq.so.4 libpq.a libpq.so.5

>
> The order doesn't matter after you've marked all but the most
> current library with F_LOADONLY.


Thank you indeed, that is exactly what I am looking for!

Yours,
Laurenz Albe
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:11 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com