ldd Command Examples in Linux

The ldd(1) (list dynamic dependencies) command displays the shared libraries that a program (or a shared library) requires to run. Here’s an example:

$ ldd prog
         libdemo.so.1 => /usr/lib/libdemo.so.1 (0x40019000)
         libc.so.6 => /lib/tls/libc.so.6 (0x4017b000)
         /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

The ldd command enables a user to view shared library dependencies for an application. This can be useful for troubleshooting or gathering information about system requirements for an application.

Syntax

The syntax of the ldd command is:

# ldd [options] {program binary}

The ldd command resolves each library reference (employing the same search conventions as the dynamic linker) and displays the results in the following form:

library-name => resolves-to-path

ldd Command Examples

1. Display shared library dependencies of a binary:

# ldd path/to/binary

2. Display all information about dependencies:

# ldd --verbose path/to/binary

3. Display unused direct dependencies:

# ldd --unused path/to/binary

4. Report missing data objects and perform data relocations:

# ldd --data-relocs path/to/binary

5. Report missing data objects and functions, and perform relocations for both:

# ldd --function-relocs path/to/binary
Related Post