Thursday, 5 November 2015


Posting this mainly as a reminder to myself...

If you ever find yourself needing to figure out a dynamic library loading problem on Linux, LD_DEBUG can be a massive help.

This is an environment variable you can set to make the dynamic linker print out a ton of useful diagnostic info. There are a number of different values which control the amount and type of diagnostics printed. One of the values is help; if you set LD_DEBUG to this and run executable it will print out a list of all the available options along with brief descriptions. For example, on my Linux workstation at the office:

> LD_DEBUG=help cat
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
  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.

Be warned: using LD_DEBUG=all will generate a lot of output!

This is documented on the man page for There are a lot of other environment variables that can control the behaviour of the dynamic linker too, so it's worth a read.