Kenwood HP 9000 Personal Computer User Manual


 
Chapter 5 153
Creating and Using Libraries
Version Control with Shared Libraries
Figure 5-5
During a link, the linker records the file name of the opened library in
the shared library list of the output file. However, if the shared library is
a file system link to the actual library, the linker does not record the
name of the library the file system link points to. Rather it records the
name of the file system link.
For example, if /tmp/libmine.sl is a file system link to
/X/libapp.sl, the following command records /tmp/libmine.sl in
a.out, not /X/libapp.sl as might be expected:
$ ld /opt/langtools/lib/crt0.o main.o -L /tmp -lmine -lc
To use library-level versioning in this situation, you must set up
corresponding file system links to make sure older applications linked
with the older libraries run with these libraries. Otherwise, older
applications could end up running with newer shared libraries. In
addition, you must include the absolute path name in the internal name
of the new library.
For example, in 32-bit mode, to make the above example work correctly
with library-level versioning, first implement library-level versioning
with the actual library /X/libapp.sl and include the absolute path in
the internal name of the new library:
$ mv /X/libapp.sl /X/libapp.0 Rename old version.
$ ld -b -o /X/libapp.1 +h /X/libapp.1 *.o Create new version.
$ ln -s /X/libapp.1 /X/libapp.sl Set up symbolic link.
Then set up the corresponding file system links:
$ ln -s /X/libapp.0 /tmp/libmine.0 Link to old version.
$ ln -s /X/libapp.1 /tmp/libmine.1 Link to new version.
$ rm /tmp/libmine.sl Remove old link.
$ ln -s /X/libapp.sl /tmp/libmine.sl Link to the link.