Shared Libraries

Howto Display Shared Libraries

What are shared Libraries?

Shared Libraries are an area where object code has been compiled and grouped generally into a single file (library). In many cases, code that can be shared by more than one application can be removed and compiled into a shared area. Generally there are two types of shared libraries:

Static Libraries

Statically linked programs tend to get large because they include executable files for all of the library functions linked into them. Statically Linked programs often use more memory when other programs that are currently running contain the same library functions. Statically Linked Libraries are identified by an extension of ".a". To avoid some of the issues encountered by using static libraries, many programs will use what is known as "Dynamically Linked" libraries.

Dynamic Libraries

Dynamically Linked libraries allow multiple programs to share the same library code in memory which results in a smaller memory footprint. Dynamically linked libraries are shared amongst multiple programs. The term "Shared Libraries" often relates to dynamically linked libraries. Dynamic Libraries have the extension of ".so"

Displaying Shared Library Dependencies

The "ldd" command can be used to print the shared libraries required by each program or shared library specified on the command.

ldd command

ldd example:

ls001a:/usr/lib # ldd /bin/bash =>  (0x00007fffe35eb000) => /lib64/ (0x00007fc30e349000) => /lib64/ (0x00007fc30e145000) => /lib64/ (0x00007fc30ddd0000) => /lib64/ (0x00007fc30db88000)
        /lib64/ (0x00007fc30e5bd000)

Syntax: ldd [OPTION]... FILE...

              Print the version number of ldd.

       -v --verbose
              Print all information, including, for example, symbol versioning information.

       -u --unused
              Print unused direct dependencies.  (Since glibc 2.3.4.)

       -d --data-relocs
              Perform relocations and report any missing objects (ELF only).

       -r --function-relocs
              Perform relocations for both data objects and functions, and report any missing objects or functions (ELF only).

       --help Usage information.

Linking Shared Libraries

Dynamically linked executables are examined at their runtime by "" the Shared Object Dynamic Linker. "" checks for any dependencies in the executable and then attempts to satisfy these. If is unable to satisfy these dependencies, then the executable will fail.

Library Path

For an executable to find the necessary libraries to link with at its run time, the system has to be configured so that these libraries can be found. There are several ways this can be achieved:


Add your library directory into the location "/etc/". Once your entry has been added, you must issue the "ldconfig" command as the root user to complete the process.


Use the environment variable LD_LIBRARY_PATH to point to the directory paths containing the shared object library. Multiple directories can be added separated by a colon ":".


This entry can be added into your .bashrc file located in your home directory. (Amend accordingly)

ldconfig command

ldconfig is used to configure dynamic linker run time bindings. ldconfig creates the necessary links and cache to the most recent shared libraries found in the directories specified from the command line, in the file /etc/, and in the trusted directories (/lib and /usr/lib). This cache is used by the run time linker "". ldconfig must be run when any changes are made to the file "/etc/". This will refresh the cache of directories.

Frequently used options for ldconfig

       -v     Verbose  mode.   Print  current version number, the name of each directory as it is scanned, and any links that are
              created.  Overrides quiet mode.

       -n     Only process directories specified on the command line.  Don't process the trusted directories (/lib and  /usr/lib)
              nor those specified in /etc/  Implies -N.

       -N     Don't rebuild the cache.  Unless -X is also specified, links are still updated.

       -X     Don't update links.  Unless -N is also specified, the cache is still rebuilt.

       -f conf
              Use conf instead of /etc/

       -C cache
              Use cache instead of /etc/

       -r root
              Change to and use root as the root directory.

       -l     Library mode.  Manually link individual libraries.  Intended for use by experts only.

       -p     Print the lists of directories and candidate libraries stored in the current cache.

Files associated with ldconfig command


run time linker/loader


File containing a list of colon, space, tab, newline, or comma-separated directories in which to search for libraries.


File containing an ordered list of libraries found in the directories specified in /etc/