Kenwood HP 9000 Personal Computer User Manual


 
Chapter 5 151
Creating and Using Libraries
Version Control with Shared Libraries
1. Name the first version of your shared library with an extension of .0
(that's the number zero), for example libA.0. Use the +h option to
designate the internal name of the library, for example, libA.0:
ld -b *.o -o libA.0 +h libA.0 Creates the shared library libA.0.
2. Since the linker still looks for libraries ending in .sl with the -l
option, create a symbolic link from the usual name of the library
ending in .sl to the actual library. For example, libA.sl points to
libA.0:
ln -s libA.0 libA.sl libA.sl is a symbolic link to libA.0.
3. Link applications as usual, using the -l option to specify libraries.
The linker searches for libA.sl, as usual. However, if the library it
finds has an internal name, the linker places the internal name of the
library in the executable's shared library dependency list. When you
run the application, the dynamic loader loads the library named by
this internal name. For example:
ld /opt/langtools/lib/crt0.o prog.o -lA -lc Binds a.out with libA.0.
Creating a New, Incompatible Version of the Library
When you create a new version of the library with incompatible changes,
repeat the above steps except increment the number in the suffix of the
shared library file name. That is, create libA.1 rather than libA.0 and
set the symbolic link libA.sl to point to libA.1. Applications linked
with libA.0 continue to run with that library while new applications
link and run with libA.1. Continue to increment the suffix number for
subsequent incompatible versions, for example libA.2, libA.3, and so
forth.
Migrating an Existing Library to Use Library-Level
Versioning
If you have an existing library you can start using library-level
versioning. First rename the existing library to have the extension .0.
Then create the new version of the library with the extension .1 and an
internal name using the .1 extension. Create a symbolic link with the
extension .sl to point to the .1 library.