Search code examples
linuxshared-librariesstatic-librariesldldd

Does ldd reports all dependencies of a library?


Let's suppose we have a shared library named utils.so. It may contain undefined symbols. Suppose also that ldd reports that this library depends on some other libraries:

$ ldd utils.so
  library1.so
  library2.so
  ...
  libraryN.so

(Bt the way is it possible that utils.so depends not only on some shared libs, but on some static libs also?)

Is it true that all undefined symbols of utils.so are resolved by libraries library1.so, library2.so, ... , libraryN.so?

And the same question about static libraries - is it true that all undefined symbols of a static library are resolved by libraries that ldd reports?


Solution

  • Is it true that all undefined symbols of utils.so are resolved by libraries library1.so, library2.so, ... , libraryN.so

    Not necessarily. You can create a shared library with no dependencies but with undefined symbols. Such a library will work fine if the symbols are provided by the executable (or by shared libraries that already happen to be loaded), and fail to load otherwise. It is not recommended to create such libraries unless there's a specific need to resolve a symbol against the executable.

    And the same question about static libraries

    ldd has nothing to do with static libraries, it cannot read them or report anything about them. Static libraries don't have dependencies. They are more or less dumb archives of objects.