/usr/local/lib/libfoo.sl, and the directory path list contains /apps/lib:xyz, the dynamic loader searches for /apps/lib/libfoo.sl, then ./xyz/libfoo.sl.

The full library path name stored in the executable is referred to as the default library path. To cause the dynamic loader to search for the library in the default location, use a null directory path ().

NOTE: The use of null directory path () is PA32 specific.

When the loader comes to a null directory path, it uses the default shared library path stored in the executable. For instance, if the directory path list in the previous example was /apps/lib::xyz, the dynamic loader searches for /apps/lib/libfoo.sl, /usr/local/lib/libfoo.sl, then ./xyz/libfoo.s.

If the dynamic loader cannot find a required library in any of the directories specified in the path list, it searches for the library in the default location () recorded by the linker.

Moving Libraries After Linking with +s and SHLIB_PATH

A library can be moved even after an application has been linked with it. Linking the program with +s, enables the program to use the path list defined by the SHLIB_PATH environment variable at run time.

Specifying a Path List with +s and SHLIB_PATH

When a program is linked with +s, the dynamic loader gets the library path list from the

SHLIB_PATH environment variable at run time. This is especially useful for application developers who do not know where the libraries reside at run time. In such cases, they can have the user or an install script set SHLIB_PATH to the correct value.

For more information:

“The Path List” (page 42)

provides additional details about the path list to SHLIB_PATH.

“Moving Libraries after Linking with +b” (page 41) provides another way to move libraries.

Ignoring Dynamic Path Environment Variables with +noenvvar

Use the +noenvvar option to instruct the dynamic loader not to look at the environment variables relating to dynamic path searching at runtime. It ignores LD_LIBRARY_PATH, SHLIB_PATH, and $ORIGIN environment variables. This option is on by default in PA32 mode and in programs linked with ld +compat. It is off by default with ld +std.

For example, if libbar.so has dependent library libfee.so that is found in ./ at link time, but is moved to /tmp by runtime:

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

$ export LD_LIBRARY_PATH=/tmp $ mv libbar.so /tmp

$ a.out

called bar() called fee()

$ mv /tmp/libbar.so ./

$ ld main.o +noenvvar -L. -lbar -lc $ mv libbar.so /tmp

$ a.out

dld.so: Unable to find library "libbar.so"

Using Linker Commands 43