Linking Shared Libraries
Dynamically linked executables are examined at runtime by the shared object dynamic linker, ld.so. This program looks for dependencies in the executable being loaded and attempts to satisfy any unresolved links to system-shared libraries. If ld.so can’t find a specified library, it fails, and the executable won’t run.
To find a new library, ld.so must be
instructed to look in /usr/local/lib. There are a
few ways to do this. One simple way is to add a colon-separated list
of directories to the shell environment variable
LD_LIBRARY_PATH, which will prompt
ld.so to look in any directories it finds there.
However, this method may not be appropriate for system libraries,
because users might not set their
To make the search of /usr/local/lib part of the default behavior for ld.so, files in the new directory must be included in an index of library names and locations. This index is /etc/ld.so.cache. It’s a binary file, which means it can be read quickly by ld.so. To add the new library entry to the cache, first add its directory to the ld.so.conf file, which contains directories to be indexed by the ldconfig utility.