HP-UX Linker and Libraries User's Guide

In PA-32 mode, the dynamic loader searches shared libraries using a depth-first search order. The
diagram below illustrates a sample program with shared libraries and compares the two search
methods:
a.out
|
|-----------------|
| |
lib1 lib2
|
lib3
Breadth-first search list: a.out -> lib1 -> lib2 -> lib3
Depth-first search list: a.out -> lib1 -> lib3 -> lib2
The commands to build the libraries and the executable in "Search Order of Dependent Libraries"
are shown:
$ ld -b lib2.o -o lib2.s
$ ld -b lib3.o -o lib3.s
$ d -b lib1.o -L. -l3 -o lib1.s
$ cc main.o -Wl,-L. -l1 -l2 -o main
In PA-32 mode, if a procedure called same_name() is defined in both lib3 and lib2, main
calls the procedure defined in lib3. In PA-64 and IPF (32-bit and 64-bit), main calls the procedure
in lib2.
System Libraries - Locations and Library Name Extension
This section describes the system library locations and changes to the library name extension.
System Library Location
IPF HP-UX systems provide two new subdirectories called hpux32 and hpux64 under /usr/lib
directory for IPF system and HP product libraries.
The diagram below shows the new directory structure:
/(root)
|
|-------------------------------------|
| |
opt usr
| |
application lib
| |
lib |----------|---------|
| | |
|----|-----| hpux32 hpux64
hpux32 hpux64
The linker automatically finds the correct set of system libraries depending on whether the application
is compiled as a 32-bit or 64-bit application. Library providers are encouraged to supply both
32-bit and 64-bit versions of application libraries. Be sure to develop a strategy for library naming
conventions, directory structures, link-time options, and run-time environment variables.
Shared Library Extension (suffix)
IPF (32-bit and 64-bit) shared libraries are suffixed with .so while the PA-RISC shared libraries are
suffixed with .sl. The IPF linker supports shared libraries with both .so and .sl extension.
For example, /usr/lib/hpux32/libc.so is the IPF system 32-bit C library whereas
/usr/lib/libc.sl is the PA-RISC system 32-bit C library.
System Libraries - Locations and Library Name Extension 87