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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| |||
| 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. |
| ||||
| 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 |