Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The Linux ldd command can show the dynamic libraries used by an executable. It's a bash script. But it seems to be fragile, and does not work on some binaries. Is there an alternative tool?

In my specific example, I can use:

% file datab2txt

datab2txt: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, for GNU/Linux 2.4.0, not stripped

but ldd fails with:

% ldd -v datab2txt

not a dynamic executable

share|improve this question
The module doesn't depend on dynamically loading any libraries. The ldd command does work in this case. – BillThor Mar 23 '11 at 18:49

You could also do:

readelf -d executable | grep NEEDED

But this probably doesn't do what you want. It shows the libs that executable links to, but not all the libs it needs (a library can require another library).

share|improve this answer

The output of file says "statically linked". ldd only works on dynamically linked executables.

(Technically, all Linux ldd does is invoke the Linux executable loader, /lib/, after setting an environment variable. So it should be the most reliable way.)

Some programs might be using dlopen() to load libraries, in order to avoid making the program hard-depend on them. For example, Glibc loads NSS libraries that way because their names are only known at run time, not time of compiling/linking.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .