Search code examples
c++ldd

ldd show duplicated shared library


I have no clear why ldd shows me the same shared library more than once when it cannot find a dependency. In a little executable that uses boost, the output is:

libboost_chrono.so.1.49.0 => not found
libboost_system.so.1.49.0 => not found
libboost_system.so.1.49.0 => not found
libboost_program_options.so.1.49.0 => not found
libboost_regex.so.1.49.0 => not found

otherwise after installing the correct dependencies ldd shows only one:

libboost_system.so.1.49.0 => /usr/lib/libboost_system.so.1.49.0 
libboost_regex.so.1.49.0 => /usr/lib/libboost_regex.so.1.49.0 
libboost_program_options.so.1.49.0 => /usr/lib/libboost_program_options.so.1.49.0
libboost_chrono.so.1.49.0 => /usr/lib/libboost_chrono.so.1.49.0 

why does this happen?

Thanks,


Solution

  • The 2nd time around, ldd finds the shared library, and caches the information so it doesn't need to keep looking for it.

    However in your first situation, it can't find the shared library, so has nothing to cache. And so when it finds another reference to what you know should be the same shared library, all it knows is that it hasn't found it, so it looks for it. Then prints the error a 2nd time.