Linux 6 - Manage Shared Libraries
- what are shared libraries
- determining associated libraries
- configuring system
- ldd, lddconfig
- ld.so.cache, ld.so.conf.d
A shared library or shared object is a file that is intended to be shared by executable files and further shared objects files.
Modules used by a program are loaded from individual shared objects into memory at load time or run time, rather than being copied by a linker when it creates a single monolithic executable file for the program.
The shared library is in essence a DLL file from Windows. The main advantage is that if two programs need to use the same functions that these libraries provide then they can do so without sacrificing memory.
<add out ldd>
root@debian:~# ldd /bin/ls
linuxvdso.so.1 => (0x00007fffa35ff000)
libselinux.so.1 => /lib/libselinux.so.1 (0x00007f28e0ef4000)
librt.so.1 => /lib/librt.so.1 (0x00007f28e0cec000)
libacl.so.1 => /lib/libacl.so.1 (0x00007f28e0ae4000)
libc.so.6 => /lib/libc.so.6 (0x00007f28e0782000)
libdl.so.2 => /lib/libdl.so.2 (0x00007f28e057e000)
/lib64/ldlinuxx8664.so.2 (0x00007f28e1123000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00007f28e0361000)
libattr.so.1 => /lib/libattr.so.1 (0x00007f28e015d000)
root@debian:~#
The output shows you what libraries are needed. ldd also looks at a cache file.
root@debian:~# cd /etc/
root@debian:/etc# ls | grep ld
ldap
ld.so.cache
ld.so.conf
ld.so.conf.d
wildmidi
root@debian:/etc#
ld.so.cache
- contains a cache file for libraries
- it’s a binary file not a text file
- how this file is created depends on the ld.so.conf conf file
root@debian:/etc# cat ld.so.conf
include /etc/ld.so.conf.d/*.conf
- this means to include every .conf file in the /etc/ld.so.conf.d folder
root@debian:/etc/ld.so.conf.d# ls
libc.conf vmwaretoolslibraries.conf x86_64linuxgnu.conf
root@debian:/etc/ld.so.conf.d#
root@debian:/etc/ld.so.conf.d# cat vmwaretoolslibraries.conf
/usr/lib/vmwaretools/lib32/libvmGuestLib.so
/usr/lib/vmwaretools/lib64/libvmGuestLib.so
/usr/lib/vmwaretools/lib32/libvmGuestLibJava.so
/usr/lib/vmwaretools/lib64/libvmGuestLibJava.so
/usr/lib/vmwaretools/lib32/libDeployPkg.so
/usr/lib/vmwaretools/lib64/libDeployPkg.so
root@debian:/etc/ld.so.conf.d#
it shows all of the libraries files that the different vmware binaries will be looking for
root@debian:/etc/ld.so.conf.d# cat libc.conf
# libc default configuration
/usr/local/lib
root@debian:/etc/ld.so.conf.d# cat x86_64linuxgnu.conf
# Multiarch support
/lib/x86_64linuxgnu
/usr/lib/x86_64linuxgnu
root@debian:/etc/ld.so.conf.d#
All of the files inside these folders will be included when the cache is created
To create the cache:
ldconfig
–when the OS is finished installing new applications it will run ldconfig
–to be sure that the all of the needed libraries will exist in the cache
export LD_LIBRARY_PATH=/path/to/libs
–it will look there before anywhere elese
–not the greatest available