When developing for native platform, I can use ldd to list all the shared libraries (.so files) a binary executable I build will try to load upon start-up. But when cross-compiling, I don't know how to get the same information. The ldd
is not a normal binutils utility, like strip
or ar
, that can be built alongside gcc
for cross compiling, but instead, it is a cryptic shell script that apparently can only run on native platform.
So, using the cross-target binutils tools, is there any way to get a list of the dynamically linked dependency for of a foreign binary?
while in
gdb
, info shared is similar toldd
. It gives complete human readable runtime information of the executable.readelf
would miss path and other libraries information.readelf
is a very good tool for on the host study. Developer may choose that works.some depends idiot just uploaded this. i'm sure it shows things LDD doesn't but it's not well tested yet. a small bit of output is shown below.
http://sourceforge.net/p/dep-trace/
http://sourceforge.net/projects/dep-trace/files/libdeps
should show total dependancy table of what ldconfig(1) will load (or has already loaded) and show which libs are NOT_FOUND (ie, no version or file) and then also what is effected.
try it, enjoy. it's very new so don't say i didn't tell you. it did just find some things below i didn't know about my lib system - i'm just about to go fix that.
A bit late for this addition but someone might benefit/clarify. Doesn't the -A flag to readelf give the same result as ldd?
The only info missing here seems to be the full path where those libraries are located.
On the other hand, the tools mentioned so far are only useful once you have an installation known to work. My most common problems are:
Can anyone shed some light on these issues? BTW, I have tried reading installation instructions and release notes but they are almost always nowhere near sufficient.
A beefy example may put everything into context, so please try compiling Cinelerra.
Sorry to make a zombie thread, but I am working on some things for my OpenWRT router and wanted this to check some dependencies to see if I had enough space on my jffs2 partition to copy over just
e2fsck
. Short answer: nope.avi.Anyhoo, I made a little script that uses the accepted answer plus some (probably overly verbose)
grep
calls and with a little hand waving and some unicorn tears (no worries, they were happy tears!) I managed to put together the following script that gives you all the dependencies. I'm sure there's lots of room for improvement especially RE: the loops and recursion, as well as the fact that it's all bashisms all the time (i.e. indexed arrays) but this is at least nominally working for me:So, there ya go. Hope it helps someone. Egads it's taken me a long time to even get good enough with shell scripting to be able to pull something like this off, nevermind the fact that it took me much longer than it probably should have, so please forgive what has likely shaken some of you script gurus out there to the very core of your being. :)
You can list direct dependencies of a binary easily enough:
I know of no way to recursively continue this to get the full list (as
ldd
does). You'll have to repeat the process for everyNEEDED
library by hand.To list shared libraries dependency of a non-native binary, you can try the following tool: http://www.mathembedded.com/component/k2/item/1-cross-ldd.html
I use it on SH4 and MIPS. As reported in other answer, you can achieve the same using readelf output and a recursive loop, but I have never try by myself since cross-ldd exist.