LPI Linux Certification/Manage Shared Libraries
(LPIC-1 Version 5.0)
Candidates should be able to determine the shared libraries that executable programs depend on and install them when necessary.
Key knowledge areas:
- Identify shared libraries.
- Identify the typical locations of system libraries.
- Load shared libraries.
The following is a partial list of the used files, terms and utilities:
A library is a set of functions that programs can use to implement their functionalities. When building (linking) a program, those libraries can be statically or dynamically linked to an executable. Static link means that the final program will contain the library function within its file. (lib.a) Dynamic link means that the needed libraries would need to be loaded into RAM when the program needs to be executed. (lib.so)
The default directories for all the standard libraries are:
- /lib: Used mainly by /bin programs.
- /usr/lib: Used mainly by /usr/bin programs.
The file /etc/ld.so.conf is used by the system to specify other library locations. To build a cache file used by the runtime loader of all the available libraries, use ldconfig. The file /etc/ld.so.cache will be generated.
To print shared programs or library dependencies, use ldd.
ldd [-vdr] program|library
$ ldd -d -v /bin/cp libc.so.6 => /lib/libc.so.6 (0x40027000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) Version information: /bin/cp: libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.1) => /lib/libc.so.6 libc.so.6 (GLIBC_2.2) => /lib/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/libc.so.6 /lib/libc.so.6: ld-linux.so.2 (GLIBC_2.1.1) => /lib/ldlinux.so.2 ld-linux.so.2 (GLIBC_2.2.3) => /lib/ldlinux.so.2 ld-linux.so.2 (GLIBC_2.1) => /lib/ldlinux.so.2 ld-linux.so.2 (GLIBC_2.2) => /lib/ld-linux.so.2 ld-linux.so.2 (GLIBC_2.0) => /lib/ld-linux.so.2
The runtime loader ld.so finds the needed library of a program and will load them into RAM. The search order of ld.so is:
- The cache file /etc/ld.so.cache
- The default directories /lib and /usr/lib.