[NTLUG:Discuss] Locating shared libraries (was Re: Failed Dependacies)
Richard Cobbe
cobbe at airmail.net
Sun Sep 30 12:00:38 CDT 2001
Lo, on Saturday, September 29, Jack Snodgrass did write:
> Libraries are searched in the normal, execute path.
Not true. The PATH environment variable has nothing to do with locating
shared libraries.
See the ld.so(8) manpage for more details, but the Linux loader finds
shared libraries according to the following algorithm:
1) Search the directories in the LD_LIBRARY_PATH environment variable, in
the order in which they appear. (Use $LD_AOUT_LIBRARY_PATH for old a.out
executables.)
2) If the library isn't in any of those directories (or if $LD_LIBRARY_PATH
is empty or unset), search the directories listed in /etc/ld.so.conf.
3) If the library isn't in any of those directories either, search the
standard system directories, /usr/lib and /lib (in that order).
4) If the library isn't in those directories either, print an error message
and abort the load.
(In reality, steps 2 and 3 appear to be combined into a single search of
/etc/ld.so.cache, which is constructed from /etc/ld.so.conf when you run
ldconfig(8). Most distros that I'm aware of rebuid the library cache on
bootup.)
On a well-configured Linux system, /etc/ld.so.conf should contain all of
the necessary directories, and in any case most of the libraries should be
in /usr/lib and /lib. Therefore, unlike other Unixes, you typically don't
need to set LD_LIBRARY_PATH except in special cases.
Other Unices behave in a similar fashion, except that I think most of them
don't use /etc/ld.so.{conf,cache}---Solaris 2.6, ferinstance, only uses
LD_LIBRARY_PATH.
Richard
More information about the Discuss
mailing list