[[linux_wiki:library_paths]]

Library Paths

General Information

Configuring and viewing OS library paths.

Checklist

  • Distro(s): Enterprise Linux 6/7

Library Config Files

Main Config File: /etc/ld.so.conf includes a directory

include ld.so.conf.d/*.conf


Directory of drop in paths: /etc/ld.so.conf.d/
Example: /etc/ld.so.conf.d/mylibraries.conf

/data/lib/application1/
/data/lib/application2/


Apply Changes: If any changes are made to the above config files, run ldconfig to reload the library cache

ldconfig -v
  • -v ⇒ verbose


Print the Cache Contents: To see what is currently in the library cache

ldconfig --print-cache

Library Search Order

Shared libraries needed by programs are searched for in this order:

  • Environment variable “LD_LIBRARY_PATH” ⇒ This environmental variable can be set like any other environment variable. (shell, .bashrc, .profile)
  • (ELF binaries only) ⇒ Directories specified within the binary. (DT_RUNPATH)
  • From cache file (/etc/ld.so.cache) ⇒ created via ldconfig
  • In default system library paths (/lib, /lib64, /usr/lib)

Override Search Order

To get a path specified in front of another, define the environmental variable “LD_LIBRARY_PATH” in a configuration file (per user or system wide).


Example: Ensure that /usr/lib64 is ahead of /usr/local/lib for user “robert”

vim /home/robert/.bashrc
 
LD_LIBRARY_PATH=/usr/lib64:${LD_LIBRARY_PATH}
  • Including the “${LD_LIBRARY_PATH}” as a second entry ensures that nothing is completely over written if the variable has been set elsewhere

  • linux_wiki/library_paths.txt
  • Last modified: 2019/05/26 03:50
  • (external edit)