Linux command
ldconfig 命令
安全
权限或系统影响较大,执行前请核对目标。
常用示例
Update symlinks and rebuild the shared library cache
sudo ldconfig
Update symlinks for a specific directory only
sudo ldconfig -n [path/to/directory]
Print cached libraries and search for a specific library
ldconfig -p | grep [library_name]
Rebuild cache with verbose output
sudo ldconfig -v
Use an alternate configuration file
sudo ldconfig -f [path/to/ld.so.conf]
说明
ldconfig configures the dynamic linker run-time bindings. It creates the necessary symbolic links and cache (stored in /etc/ld.so.cache) to the most recent shared libraries found in directories specified in /etc/ld.so.conf, in trusted directories (/lib and /usr/lib), and those specified on the command line. The cache is used by the run-time linker (ld.so or ld-linux.so) to quickly resolve shared library dependencies without scanning directories at load time. Running ldconfig is typically necessary after installing new shared libraries or modifying /etc/ld.so.conf.
参数
- -n
- Process only specified directories (don't update cache)
- -p, --print-cache
- Print libraries stored in the cache
- -v, --verbose
- Verbose mode
- -N
- Don't rebuild the cache
- -X
- Don't update symbolic links
- -f _FILE_
- Use specified config file instead of /etc/ld.so.conf
- -C _FILE_
- Use specified cache file instead of /etc/ld.so.cache.
- -r _ROOT_
- Change to and use _ROOT_ as the root directory.
- -l
- Library mode. Manually link individual libraries.
FAQ
What is the ldconfig command used for?
ldconfig configures the dynamic linker run-time bindings. It creates the necessary symbolic links and cache (stored in /etc/ld.so.cache) to the most recent shared libraries found in directories specified in /etc/ld.so.conf, in trusted directories (/lib and /usr/lib), and those specified on the command line. The cache is used by the run-time linker (ld.so or ld-linux.so) to quickly resolve shared library dependencies without scanning directories at load time. Running ldconfig is typically necessary after installing new shared libraries or modifying /etc/ld.so.conf.
How do I run a basic ldconfig example?
Run `sudo ldconfig` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -n do in ldconfig?
Process only specified directories (don't update cache)