ldconfig is a command-line tool in Linux used to update the shared library cache. It is responsible for configuring the dynamic linker runtime bindings. The dynamic linker is responsible for resolving symbols at runtime, which means that it loads shared libraries and links them with the executable file. The
ldconfig command is used to manage the shared libraries and their dependencies in a system.
ldconfig command is used to update the shared library cache. It scans the directories specified in the
/etc/ld.so.conf file and the trusted directories (
/usr/local/lib, etc.) to find shared libraries. It then creates a cache of the shared libraries and their dependencies. When a program is executed, the dynamic linker uses this cache to locate the required shared libraries.
ldconfig [-nNvXV] [-f conf] [-C cache] [-r root] [-l loader] [-p] [-c] [-d] [-D] [-A] [-q] [-a arch] [-R relro] [-u] [directories...]
- Update the shared library cache:
- Add a directory to the list of directories to be searched for shared libraries:
sudo ldconfig /usr/local/lib
- Show the contents of the shared library cache:
- Update the cache for a specific path:
sudo ldconfig /usr/local/lib64/
Specific Use Cases
ldconfig command is useful in the following scenarios:
- When a new shared library is installed,
ldconfigmust be run to update the cache so that the dynamic linker can find it.
- When a shared library is removed,
ldconfigmust be run to remove the library from the cache.
- When a library is upgraded,
ldconfigmust be run to ensure that the latest version of the library is used.
The following table lists the available options for the
||Do not execute anything; just print what would be done.|
||Do not update the cache.|
||Do not use cached data.|
||Print the version number and exit.|
||Use the specified configuration file instead of
||Use the specified cache file instead of
||Set the root directory.|
||Set the dynamic linker.|
||Print the contents of the cache.|
||Create the cache.|
||Delete the cache.|
||Show the differences between the old and new cache.|
||Add the specified directories to the cache.|
||Set the architecture.|
||Set the relro mode.|
||Remove unused cache entries.|
- If a shared library is not found, check that it is installed and that its directory is listed in the
- If a shared library is found but not used, check that it is the correct version and that it is listed before any other versions in the
- If a shared library is not updated after an upgrade, run
ldconfigto update the cache.
ldconfigcommand should be run as root or with sudo privileges.
ldconfigcommand is part of the GNU C Library (glibc) package.