Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




12.3 Finding dynamically linked libraries

When a program has been compiled using shared libraries it needs to load those libraries dynamically at run-time in order to call external functions. The command ldd examines an executable and displays a list of the shared libraries that it needs. These libraries are referred to as the shared library dependencies of the executable.

For example, the following commands demonstrate how to find the shared library dependencies of the Hello World program:

$ gcc -Wall hello.c
$ ldd a.out => /lib/ (0x40020000)
/lib/ => /lib/ (0x40000000)

The output shows that the Hello World program depends on the C library libc (shared library version 6) and the dynamic loader library ld-linux (shared library version 2).

If the program uses external libraries, such as the math library, these are also displayed. For example, the calc program (which uses the sqrt function) generates the following output:

$ gcc -Wall calc.c -lm -o calc
$ ldd calc => /lib/ (0x40020000) => /lib/ (0x40041000)
/lib/ => /lib/ (0x40000000)

The first line shows that this program depends on the math library libm (shared library version 6), in addition to the C library and dynamic loader library.

The ldd command can also be used to examine shared libraries themselves, in order to follow a chain of shared library dependencies.

  Published under the terms of the GNU General Public License Design by Interspire