$ ar tv libunits.a |
|
|
|
|
|
|
| |
265/ | 20 | 230 | Feb | 2 | 17:19 1990 | length.o | ||
265/ | 20 | 228 | Feb | 2 | 16:25 | 1990 | mass.o | |
265/ | 20 | 230 | Feb | 2 | 16:24 | 1990 | volume.o |
The next example replaces length.o in libunits.a, only if length.o is more recent than the one already contained in libunits.a:
$ ar ru libunits.a length.o
crt0.o
The crt0.o startup file is not needed for shared bound links because dld.so does some of the startup duties previously done by crt0.o. However, you still need to include crt0.o on the link line for all fully archive links (ld
Users who link by letting the compilers such as cc invoke the linker do not have to include crt0.o on the link line.
Archive Library Location (IPF)
After creating an archive library, you can save it in a location that is easily accessible to other programmers who may want to use it. There are two main choices for places to put the library:
•in the
•in the
Using /usr/lib and /usr/lib/pa20_64
Because the linker searches /usr/lib or /usr/lib/pa20_64 by default, you may put your archive libraries in /usr/lib or /usr/lib/pa20_64 and thereby eliminate the task of entering the entire library path name each time you compile or link.
The drawbacks of putting the libraries in /usr/lib or /usr/lib/pa20_64 are:
•You usually need
•You may inadvertently overwrite an
Check with your system administrator before attempting to use /usr/lib or /usr/lib/pa20_64.
Using /usr/local/lib or /usr/contrib/lib
The /usr/local/lib and /usr/local/lib/pa20_64 library typically contain libraries created locally - by programmers on the system; /usr/contrib/lib and /usr/contrib/lib/pa20_64contain libraries supplied with
Creating Shared Libraries
Two steps are required to create a shared library:
1.Compile one or more source files to create object files. In
2.“Creating the Shared Library with ld” (page 99) by linking with
98 Creating and Using Libraries