Libtree: Ldd as a tree saying why a library is found or not
github.com
github.com
This seems to actually manually parse the ELF file and recursively parse any dependencies.
Pretty cool.
See: https://manpages.debian.org/unstable/manpages/ldd.1.en.html#...
Use https://github.com/lucasg/Dependencies instead (even though that isn't exactly up-to-date either...)
If you have Visual Studio installed (and have selected the 'x64/x86 build tools (latest)' in the installer), `dumpbin /dependents` from a VS Developer Command Prompt remains the most reliable option.
Magenta: In exclude list (only shown with -v[v[v]])
Blue: Seen before (so you can spot which dependencies appear multiple times)
There is the system search path, runpath, rpath, and LD_LIBRARY_PATH as just a few different distinct methods library searched on directories.
Libraries are also usually linked just by the short name, IE foo.so, but they can also be dynamically linked to the full path of the library.
Side note, as a general rule if you can avoid setting the LD_LIBRARY_PATH you'll be much off. It's not always possible, but setting puts it at the top of the search for all executions. Even if something dynamically links the full path to a library, LD_LIBRARY_PATH will take precedence. It completely flattens the search.
The point of the title is to say that libtree makes it easy to find the paths from an executable to all its direct and indirect dependencies, one of the uses of which is to help figure out what's up with missing dependencies.
In reality if you're using a packaging system then you likely won't have missing dependencies, so you'd use libtree for other reasons.
Or RPATH, which is evaluated at load time per each library. The bigger point is that dependencies form a graph (which can be displayed as a tree) and its useful to know why a library wasn't found because of the library that required it.
It is possible to end up loading multiple versions of the same library as well, if your environment and RPATH settings are not consistent. This tool will help you figure out if you have problems and why.
at minimum you have RPATH, RUNPATH, LD_LIBRARY_PATH.
this tool is based on ldd and thus also (presumably) resolves DYLD_LIBRARY_PATH, DYLD_FALLBACK_FRAMEWORK_PATH, DYLD_FALLBACK_LIBRARY_PATH, @executable_path, @loader_path and @rpath.
Note that there are inconsistencies between glibc and musl when it comes to rpath and runpath.
1. grab the vdso offset XX in memory of, for example, the running shell
gawk -n -vFS=- '/\[vdso\]/{printf("%i",("0x"$1)/4096)}' /proc/$$/maps
2. extract that page dd if=/proc/$$/mem of=linux-vdso.so bs=4096 count=1 skip=XX
where XX is the offset from step 13. check with
nm -D linux-vdso.so
objdump -ad -j .text linux-vdso.socurl -Lfs https://raw.githubusercontent.com/haampie/libtree/master/lib... | ${CC:-cc} -o libtree -x c - -std=c99 -D_FILE_OFFSET_BITS=64
https://github.com/haampie/libtree/releases/download/v3.1.1/...
The only verification provided is a sha256sum provided in the README, there's no way to confirm what source code or compiler was used to produce the binary, and no way to verify the binary was produced by that github user / that the README sha256 I was served was untampered with.
I would propose that the 'unsafe' curl method is in fact probably safer than the recommended-first choice in the README.
alias libtree='curl -LfSs https://raw.githubusercontent.com/haampie/libtree/master/libtree.c | ${CC:-cc} -o /tmp/libtree -x c - -std=c99 -D_FILE_OFFSET_BITS=64; /tmp/libtree'
so any time you invoke `libtree` it downloads the latest version, compiles it, and runs it.With a stable internet connection, it is still faster than pax-util's lddtree, which is written in Python.
C is an excellent scripting language.