next up previous
Next: Library versions for Up: ELF under Linux Previous: ELF macros

Library locations and search paths

Under Linux, most of system libraries are installed under /usr/lib. Only a few essential shared libraries are installed in /lib. Those libraries are libc.so, libcurses.so, libm.so and libtermcap.so which are necessary for starting up the Linux system before other partitions are mounted. The default search paths for linker are /lib, /usr/lib, /usr/local/lib and /usr/i486-linux/lib in this order.

The environment variable LD_LIBRARY_PATH may hold a list of directories, separated by colons (:), which is checked by the dynamic linker to search for shared libraries. For example, the string /usr/X11R6/lib:/usr/local/lib: tells the dynamic linker to search first the directory /usr/X11R6/lib, then /usr/local/lib, and then the current directory to find the shared libraries required in addition to the default directories.

There is a new environment variable ELF_LD_LIBRARY_PATH which plays a similar role to LD_LIBRARY_PATH. Since LD_LIBRARY_PATH is also used with the old a.out DLL Linux shared libraries, to avoid unnecessary warnings from the DLL linker sometimes ELF_LD_LIBRARY_PATH is a better choice to provide additional directories to the ELF dynamic linker under Linux.

Another feature is the /etc/ld.so.conf file. This file consists of a list of directories, e.g.:

/lib/elf
/usr/X11R6/lib
/usr/local/lib
/usr/i486-linuxaout/lib

The program ldconfig will search the directories listed in /etc/ld.so.conf and store all of the shared libraries which are found in /etc/ld.so.cache. The Linux ELF dynamic linker will find the shared libraries in /etc/ld.so.cache if the shared libraries have been moved from the default directories.



J.H.M.Dassen
Tue Aug 1 14:18:10 MDT 1995