Dynamic Library Search¶
This section describes NSPR’s programming interface to load, unload and resolve symbols in dynamic libraries. It also provides a method by which to condition symbols of statically linked code so that to other clients it appears as though they are dynamically loaded.
To use the dynamic library loading functions on some platforms, certain environment variables must be set at run time, and you may need to link your executable programs using special linker options.
This section summarizes these platform idiosyncrasies. For more
information, consult the man pages for
shl_load on HP-UX) for Unix, and the
Dynamic Library Search Path¶
The dynamic library search path is the list of directories in which to look for a dynamic library. Each platform has its own standard directories in which to look for dynamic libraries, plus a customizable list of directories specified by an environment variable.
On most Unix systems, this environment variable is
LD_LIBRARY_PATH. These systems typically use
dlopento load a dynamic library.
shl_loadto load dynamic libraries, and the environment variable specifying the dynamic library search path is
SHLIB_PATH. Moreover, the executable program must be linked with the +s option so that it will search for shared libraries in the directories specified by
SHLIB_PATHat run time. Alternatively, you can enable the +s option as a postprocessing step using the
chatrtool. For example, link your executable program a.out without the +s option, then execute the following:
chatr +s enable a.out
On Rhapsody, the environment variable is
On Win32, the environment variable is
PATH. The same search path is used to search for executable programs and DLLs.
Exporting Symbols from the Main Executable Program¶
On some systems, symbols defined in the main executable program are not exported by default. On HP-UX, you must link the executable program with the -E linker option in order to export all symbols in the main program to shared libraries. If you use the GNU compilers (on any platform), you must also link the executable program with the -E option.