HP-UX Linker and Libraries User's Guide

...
libfile2a.so:
*** Dynamic Section ***
Index Tag Value
0 HPNeeded 0:/home/knish/./libfile2.1
1 HPNeeded 0:./libfile4.so
2 Rpath /var/tmp
...
Library Example: Creating an IPF Standard Mode Shared Library
The following example builds a standard mode library:
$ ld -b file1.o -o libfile1.so +h libfile1.1
$ ld -b file2.o -o libfile2.so +h ./libfile2.1
$ ld -b file3.o -o libfile3.so +h /var/tmp/libfile3.1
$ ld -b file4.o -o libfile4.so
$ ld -b file3a.o -o libfile3a.so -L. -lfile1 -lfile3 +h libfile3a.1
$ ld -b file2a.o -o libfile2a.so libfile2.so ./libfile4.so +b /var/tmp
$ elfdump -L libfile3a.so libfile2a.so
libfile3a.so:
*** Dynamic Section ***
Index Tag Value/Ptr
0 Needed libfile1.1
1 Needed /var/tmp/libfile3.1
2 Soname libfile3a.1
3 Rpath .
...
libfile2a.so:
*** Dynamic Section ***
Index Tag Value/Ptr0 Needed ./libfile2.1
1 Needed ./libfile4.so
2 Rpath /var/tmp
...
The dynamic loader does dynamic path searching for libfile1.so. It does not do dynamic
path searching for libfile2.so, libfile3.so, and libfile4.so.
Library example: IPF Dynamic Path Searching
This example of dynamic path searching demonstrates differences between compatibility mode
and standard mode dependent shared libraries. The example builds standard mode libraries and
does a standard mode link. By default, the dynamic loader looks at the environment variables
LD_LIBRARY_PATH and SHLIB_PATH to find the shared libraries.
# build standard mode shared libraries
#libfile1.so is a dependent of libfile2.so
$ ld -b file1.o -o libfile1.so +h libfile1.1
$ ld -b file2.o -o libfile2.so +h libfile2.1 -L. -lfile1
$ ld main.o -L. -lfile2 -lc
# move dependent lib so dld can't find it
# dld won't find library because we didn't set the environment
# variable LD_LIBRARY_PATH and SHLIB_PATH
# By default, dld will look at the environment variables
# LD_LIBRARY_PATH and
# SHLIB_PATH when doing dynamic path searching unless +noenvvar
# is specified
$ mv libfile2.so /var/tmp
$ ln -s /var/tmp/libfile2.so /var/tmp/libfile2.1
132 Creating and Using Libraries