A library is a collection of commonly
used functions, precompiled in object format and ready to be linked
to an application. Because different programming languages have
different calling conventions, there are separate libraries for
various languages. On HP-UX systems, the C and C++ languages use
one set of libraries, while the Fortran and Pascal languages use
another.
In the HP-UX environment there are two types of libraries:
archive libraries and shared libraries.
An
archive library is a collection of object
modules. When an application is linked with an archive library,
the linker scans the contents of the archive library and extracts
the object modules that satisfy any unresolved references in the
application. The linker copies the archive library modules into
the application's code section.
A
shared library is also a collection of object
modules. However, when the linker scans a shared library, it does
not copy modules into the application's code section. Instead,
the linker preserves information in the application's code
section about which unresolved references were resolved in each
shared library. At run time, the loader copies the referenced modules
from the shared library into memory. If multiple applications linked
with a common shared library execute simultaneously, they will all
share (or be attached to) the same physical copy of the library
in memory (hence the name shared library).
The shared library improves the efficiency of memory use and allows
smaller application binaries.
The name of an archive library is libname.a,
and the name of a shared library is libname.sl.
Thus the library named m
(for math) can have versions named libm.a
and libm.sl.
The HP-UX system libraries are in the directory /usr/lib.
By default, the HP-UX linker selects a shared version of a
library, if one is available. Although shared libraries save space
in memory, using shared libraries makes a program run more slowly.
If your application makes heavy use of math library functions, you
may want to use archive libraries instead of shared libraries. For
more information about performance issues related to shared and
archive libraries, see “Shared Libraries versus Archive
Libraries”.
For detailed information about archive libraries and shared
libraries, see the HP-UX Linker and Libraries Online User Guide.