Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


How to see library dependencies in Linux

Abdul Monum

The Linux command-line tool provides the ldd command for viewing dynamic dependencies of shared libraries, executable files, and compiled object.o files. The ldd (list dynamic dependencies) command displays the shared libraries that a program (or a shared library) requires to run. 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

NOTE: Modern Linux-based versions use the Executable and Linking Format (ELF) shared libraries. ELF supersedes the older a.out and COFF formats.

Using the ldd command

The syntax for the ldd command is as follows:

ldd [option]... file... 

Supported options include:

  • -v: Verbose mode. Print detailed output with all of the information.
  • -u: Print all unused object dependencies.
  • -d: Process data relocation and print missing ELF objects.
  • -r: Process data and function relocation, and print both missing ELF objects and functions.


In the below example, the ldd command prints the shared libraries required by the ls program, which resides in the /bin directory:

ldd /bin/ls

Output: => /lib/x86_64-linux-gnu/ (0x00007fda2039d000) => /lib/x86_64-linux-gnu/ (0x00007fda1ffac000) => /lib/x86_64-linux-gnu/ (0x00007fda1fd3a000) => /lib/x86_64-linux-gnu/ (0x00007fda1fb36000)
/lib64/ (0x00007fda207e7000) => /lib/x86_64-linux-gnu/ (0x00007fda1f917000)

Using the -v flag prints a detailed output:

ldd -v /bin/ls

Output: (0x00007fff62a99000) => /lib/x86_64-linux-gnu/ (0x00007f1552960000) => /lib/x86_64-linux-gnu/ (0x00007f155256f000) => /lib/x86_64-linux-gnu/ (0x00007f15522fd000) => /lib/x86_64-linux-gnu/ (0x00007f15520f9000)
/lib64/ (0x00007f1552daa000) => /lib/x86_64-linux-gnu/ (0x00007f1551eda000)

Version information:
/bin/ls: (GLIBC_2.14) => /lib/x86_64-linux-gnu/ (GLIBC_2.4) => /lib/x86_64-linux-gnu/ (GLIBC_2.17) => /lib/x86_64-linux-gnu/ (GLIBC_2.3.4) => /lib/x86_64-linux-gnu/ (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/ (GLIBC_2.3) => /lib/x86_64-linux-gnu/
/lib/x86_64-linux-gnu/ (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/ (GLIBC_2.3) => /lib64/ (GLIBC_2.14) => /lib/x86_64-linux-gnu/ (GLIBC_2.8) => /lib/x86_64-linux-gnu/ (GLIBC_2.4) => /lib/x86_64-linux-gnu/ (GLIBC_2.7) => /lib/x86_64-linux-gnu/ (GLIBC_2.3) => /lib/x86_64-linux-gnu/ (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/ (GLIBC_2.3.4) => /lib/x86_64-linux-gnu/
	/lib/x86_64-linux-gnu/ (GLIBC_2.3) => /lib64/ (GLIBC_PRIVATE) => /lib64/
	/lib/x86_64-linux-gnu/ (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/ (GLIBC_2.14) => /lib/x86_64-linux-gnu/ (GLIBC_2.3.4) => /lib/x86_64-linux-gnu/ (GLIBC_2.4) => /lib/x86_64-linux-gnu/ (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/ (GLIBC_2.3) => /lib/x86_64-linux-gnu/
	/lib/x86_64-linux-gnu/ (GLIBC_PRIVATE) => /lib64/ (GLIBC_PRIVATE) => /lib/x86_64-linux-gnu/ (GLIBC_2.4) => /lib/x86_64-linux-gnu/ (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/
	/lib/x86_64-linux-gnu/ (GLIBC_2.2.5) => /lib64/ (GLIBC_PRIVATE) => /lib64/ (GLIBC_2.14) => /lib/x86_64-linux-gnu/ (GLIBC_2.3.2) => /lib/x86_64-linux-gnu/ (GLIBC_2.4) => /lib/x86_64-linux-gnu/ (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/ (GLIBC_PRIVATE) => /lib/x86_64-linux-gnu/




Abdul Monum
Copyright ©2022 Educative, Inc. All rights reserved

View all Courses

Keep Exploring