Kenwood HP 9000 Personal Computer User Manual


 
Chapter 5 123
Creating and Using Libraries
Overview of Shared and Archive Libraries
Almost all system libraries are available both as a shared library and as
an archive library for 32-bit mode in the directory /usr/lib and for
64-bit mode in /usr/lib/pa20_lib. Archive library file names end
with .a whereas shared library file names end with .sl. For example, in
32-bit mode, the archive C library libc is /usr/lib/libc.a and the
shared version is /usr/lib/libc.sl. In 64-bit mode, the archive C
library libc is /usr/lib/pa20_64/libc.a and the shared version is
/usr/lib/pa20_64/libc.sl
If both shared and archived versions of a library exist, ld uses the one
that it finds first in the default library search path. If both versions exist
in the same directory, ld uses the shared version. For example,
compiling the C program prog.c causes cc to invoke the linker with a
command like this:
For 32-bit mode: ld /opt/langtools/lib/crt0.o prog.o -lc
For 64-bit mode:
ld /opt/langtools/lib/pa20_64/crt0.o prog.o -lc
The -lc option instructs the linker to search the C library, libc or
libc/pa20_64, to resolve unsatisfied references from prog.o. If a
shared libc exists (/usr/lib/libc.sl or
/usr/lib/pa20_64/libc.sl), ld uses it instead of the archive libc
address binding Addresses of library
subroutines and data are
resolved at link time.
Addresses of library subroutines are
bound at run time. Addresses of data in
a.out are bound at link time; addresses of
data in shared libraries are bound at run
time.
a.out files Contains all library
routines or data (external
references) referenced in
the program. An a.out file
that does not use shared
libraries is known as a
complete executable.
Does not contain library routines; instead,
contains a linkage table that is filled in
with the addresses of routines and shared
library data. An a.out that uses shared
libraries is known as an incomplete
executable, and is almost always much
smaller than a complete executable.
run time Each program has its own
copy of archive library
routines.
Shared library routines are shared among
all processes that use the library.
Comparing Archive Shared (or dll)