In the above example, if you type:
$ ld main.o
instead of:
$ mv libme.so /var/tmp
$ ld main.o
the linker finds libme.so in ./ at link time, and the dynamic loader finds libme.so in /var/tmp at run time. At run time, the dynamic loader searches paths to resolve external references made by main in the following order:
1. ./libc.so not found /usr/lib/hpux32/libc.so found
2.SHLIB_PATH to find libbar.so not found
3. ./libbar.so (./libbar.so) found
4.LD_LIBRARY_PATH to find libme.so not found
5.SHLIB_PATH to find libme.so not found
6./var/tmp/libme.so found
7.LD_LIBRARY_PATH to find libc.so not found
8.SHLIB_PATH to find libc.so not found
9.LD_LIBRARY_PATH to find libbar.so not found
Library Example: Linking to Libraries with +b path_list in
This example is the same as “Library Example: Linking to Libraries with +b path_list in
$ cc
$ ld +compat
$ mv libme.so /var/tmp
When linking main.o, the link order is: 1. ./libbar.so found
2. ./libme.so found
3. ./libc.so not found
4./usr/lib/libc.so found In the above example, if you type:
$ mv libme.so /var/tmp
$ ld main.o
instead of:
$ ld main.o
the linker issues the following error message:
ld: Can't find dependent library ./libme.so Fatal Error
The linker does not look in /var/tmp to find shared libraries because in
1. ./libbar.so found
2./var/tmp/libme.so found
3./libc.so not found
4./usr/lib/libc.so found
Using Shared Libraries in Default Mode 135