I know ldd
can only take a binary as its parameter what I am asking here is how to run ldd
with a binary, say, mybin
, with parameter of the binary. For instance, mybin --myparam ./configfile.conf
.
The linker will differ if I add the conf file for my binary because it loads some plugins in runtime with the plugins' shared object files, plugin1.so
something like this. I have some undefined reference issue but I still got no idea which .so
file I was missing.
If I run ldd ./mybin
, everything is linked and running the plain binary is fine. Once I add the conf file for my binary, to let it loads some plugins shared library, then my binary will report errors when loading those library(coded exception throw, with some undefined reference
error messages).
So if there is way to run ldd
with mybin --myparam ./a.file
something like this would help a lot.
Use the LD_DEBUG
environment variable for this. To see the relevant options, run any command with LD_DEBUG=help
. For example, running LD_DEBUG=help ls
on my machine gives this output:
LD_DEBUG=help ls
Valid options for the LD_DEBUG environment variable are:
libs display library search paths
reloc display relocation processing
files display progress for input file
symbols display symbol table processing
bindings display information about symbol binding
versions display version dependencies
scopes display scope information
all all previous options combined
statistics display relocation statistics
unused determined unused DSOs
help display this help message and exit
To direct the debugging output into a file instead of standard output
a filename can be specified using the LD_DEBUG_OUTPUT environment variable.
One way of debugging your dlopen
s, or whatever late loading mechanism you are using, would be to run your executables with the relevant args with LD_DEBUG=all
. This would give you a lengthy output detailing symbol lookups and search paths. This output would also tell you about resolution failures.