Skip to content
systemcoding.dev
Fundamentals

List a binary's shared library dependencies with ldd

Run ldd ./app to see which shared libraries a Linux ELF binary needs and where the loader resolves them, and never run it on a binary you do not trust.

2 min read
Summarize in AI

When a program fails to start with "cannot open shared object file", the first question is what it needs and where each library would be found. ldd answers both in one command: it lists every shared library in the dependency tree and the path the dynamic loader chose.

Shell
ldd ./hello
Text
	linux-vdso.so.1 (0x00007ffd5d9f3000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1a2c000000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f1a2c3b1000)

Each line is a library name, an arrow, the resolved file and the address it would load at. The addresses change on every run because of ASLR, and the paths are those of a Debian-style system with glibc 2.39. linux-vdso.so.1 is not a file: it is a small object the kernel maps into every process, so it has no path. A missing library shows as libfoo.so => not found, which is the line you were looking for.

The warning is in the manual: ldd may work by running the program with a special environment variable set, so the loader prints the list instead of starting main. Do not run it on a binary you do not trust, since a crafted file can execute code. For an untrusted file, objdump -p ./hello | grep NEEDED or readelf -d reads the headers without running anything, though it only shows direct dependencies. See the ldd(1) manual page.

Also inToolchains
Share

More snippets

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.