lib3.so has dependents lib3a.so and lib3b.so lib3a.so has dependent lib3aa.so

+-->lib2a.so

 

+-->lib2.so-->lib2b.so

 

lib1.so--

>lib3.so.so-->lib3a.so-->lib3aa.so

+-->lib3b.so

+-->lib4.so

In breadth-first searching, the load order is siblings before children:

lib1.so->lib2.so->lib3.so->lib4.so->lib2a.so->lib2b.so->lib3a.so->lib3b.so->lib3aa.so

In depth-first searching, the load order is children before siblings:

lib1.so->lib2.so->lib2a.so->lib2b.so->lib3.so->lib3a.so->lib3aa.so->lib3b.so->lib4.so

Library Example: Using RPATH with Standard Mode Shared Library

In the following example, the linker uses the embedded RPATH at link time to find the dependent library. For compatibility mode shared libraries, embedded RPATHs are ignored.

$ ld -b bar.o -o libbar.so

$ ld -b foo.o -o libfoo.so -L. -lbar +b /var/tmp

#ld should look in /var/tmp to find libbar.so since libfoo.so

#has an embedded RPATH of

#/var/tmp

$ mv libbar.so /var/tmp $ ld main.o -L. -lfoo -lc

#For compatibility mode dlls, embedded RPATHs are ignored $ ld -b bar.o -o libbar.so

$ ld -b foo.o -o libfoo.so +compat -L. -lbar +b /var/tmp

#ld won't find libbar.so since it does not look at embedded RPATHs $ mv libbar.so /var/tmp

$ ld main.o -L. -lfoo +compat -lc

ld: Can't find dependent library "libbar.so" Fatal error.

Linking Libraries with +b pathlist

The following examples compare PA-32 and IPF/PA-64 linking with the ld +b pathlist option. If you do not use the +b option, the dynamic loader uses the directory specified by the -L option at link time for dynamic library lookup at run time.

Library Example: Linking to Libraries with +b path_list in IPF/PA-64 Mode

$ cc -c me.c

$ ld -b me.o -o libme.so

$ ld -b bar.o -o libbar.so -L. -lme +b /var/tmp $ mv libme.so /var/tmp

$ ld main.o -L. -lbar -lc

In IPF/PA-64 mode, the linker finds libme.so in /var/tmp because the +b /var/tmp option is used when linking libbar.so. Because -lme was specified while linking libbar.so, libme.so is subject to run-time dynamic path searching. When linking main.o, the link order in the above example is:

1. ./libme.so not found

2. ./libbar.so found

3./var/tmp/libme.so found

4../libc.so not found>

5./usr/lib/hpux32/libc.so found

134 Creating and Using Libraries

Page 134
Image 134
HP UX Software Transition Kit (STK) manual Linking Libraries with +b pathlist