List a binary's runtime libraries with ldd and know its risks
ldd lists the shared libraries a program will load, but on glibc it can run the program, so use readelf -d for binaries you do not trust.
ldd answers the question every "cannot open shared object file" error raises: which libraries does this program want, and where are they found?
ldd ./app linux-vdso.so.1 (0x00007ffd5a9f2000)
libfoo.so.1 => not found
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3a1c400000)
/lib64/ld-linux-x86-64.so.2 (0x00007f3a1c6a5000)not found is the line you came for: the loader's search failed for libfoo.so.1. The addresses change on every run because of ASLR.
Now the part the one-line description leaves out. On glibc, ldd is a shell script that asks the dynamic loader to resolve the program, and for some binaries it does that by running them with LD_TRACE_LOADED_OBJECTS=1. The ldd man page warns that a program with a hostile interpreter or a crafted ELF can run its own code at that moment. So do not run ldd on a file you would not run.
A safe way to read the direct dependencies is to read the file instead of loading it:
readelf -d ./app | grep NEEDED 0x0000000000000001 (NEEDED) Shared library: [libfoo.so.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]That shows only the direct list, not the full tree, and gives no paths, because nothing was resolved. For a cross-compiled binary ldd cannot work at all, since the host cannot load a foreign architecture, and readelf or the cross toolchain's -d option is the answer. The caveat is in the ldd man page.