Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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/ld-linux.so.2, 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 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.