Skip to content

ldconfig command on Linux (library index)

The ldconfig command in Linux creates the links and reindexes the dynamic libraries in the /etc/ld.so.cache file. It searches for libraries in the /usr/lib and /lib directories, as well as in the directories listed in /etc/ld.so.conf, as well as the directory entered on the line of command.

The most common options are:

  • -p: Lists the contents of the /etc/ld.so.cache cache.
  • -v: Shows the progress of updating the cache.
  • -f: file informs another configuration file other than the default /etc/ld.so.conf.

Examples:

# ldconfig —p
229 libs found in cache '/etc/ld.so.cache'
src_vipa.so (ELF) => /usr/lib/src_vipa.so
libz.so.1 (libc6) => /lib/libz.so.1
libz.so.1 (libc6) => /usr/lib/libz.so.1
liby2util.so.3 (libc6) => /usr/lib/liby2util.so.3
liby2pm.so.2 (libc6) => /usr/lib/liby2pm.so.2
liby2.so.2 (libc6) => /usr/lib/liby2.so.2
libyui.so.2 (libc6) => /usr/lib/libyui.so.2
libycp.so.2 (libc6) => /usr/lib/libycp.so.2
# ldconfig —v
/usr/X11R6/lib:
LibSm.so.6 -> LibSm.so.6.0
libdps.so.1 -> libdps.so.1.0
LibXRender.so.1 -> LibXRender.so.1.2
(...)

LD_LIBRARY_PATH

It is still possible to provide the linker at run time ld.so with a list of extra directories that may contain shared libraries through the environmental variable LD_LIBRARY_PATH.

A list of directories can be configured, separating them by a colon “:”. This list precedes the list in the ls.so.conf file.

# set | grep LD_LIBRARY_PATH
LD_LIBRARY_PATH=/usr/lib

For security reasons, the LD_LIBRARY_PATH variable is ignored by ld.so when it connects to programs that have the SUID or SGID bit enabled.

Its use is common to test new routines in libraries under development instead of executing the routines already installed.

Every time a new library, or library version, is installed, it is necessary to update the ld.so linker cache with the ldconfig command.

Rarely, you will need to use the ldd and ldconfig commands if you install software on Linux. using a package manager, because managers also install software dependencies, so that the libraries that the software requires are also installed and the ld.so.cache file is redone when installing the packages.

But if you download software in source code and are going to compile this software, you can be sure that you will probably run into an error of lack of libraries or an incorrect version.

The list of libraries used by a program can be obtained with the ldd command.

Learn much more about Linux in our online course. You can register here. If you already have an account, or want to create one, just log in or create your user here.

Did you like it?

Share