1

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?

Alexey
  • 710
  • 3
  • 7
  • 19

1 Answers1

2

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.

n. m. could be an AI
  • 112,515
  • 14
  • 128
  • 243
  • Then could you please tell me what libraries ldd prints?? – Alexey Jan 07 '19 at 10:40
  • First line of `man ldd` says *ldd prints the shared objects (shared libraries) required by each program or shared object specified on the command line*. – n. m. could be an AI Jan 07 '19 at 10:44
  • If so then it must be true that "all undefined symbols of utils.so are resolved by libraries library1.so, library2.so, ... , libraryN.so". But you said it is not true. Could you please elaborate your answer a little bit? – Alexey Jan 07 '19 at 11:02
  • Your claim is not true for a number of reasons, but the reasons are not imporant when you can just build a counterexample in like 10 lines of code. – n. m. could be an AI Jan 07 '19 at 11:13
  • To demonstrate, http://coliru.stacked-crooked.com/a/e1c7fcefd25c4a02 sorry, more than 10 lines :( – n. m. could be an AI Jan 07 '19 at 11:22