1

When using the ldd command there is an option, -u, to

print unused direct dependencies

as stated in the on-line help.

For example:

ldd  -u /bin/gcc
Unused direct dependencies:
        /lib64/libm.so.6
        /lib64/ld-linux-x86-64.so.2

What are "unused direct dependencies"? Why are they unused? Why are they dependencies?

3

They are dependencies because the binary lists them as dependencies, as “NEEDED” entries in its dynamic section:

readelf -d /usr/bin/gcc

will show you the libraries gcc requests.

They are unused because gcc doesn’t actually need any of the symbols exported by the libraries in question. In ld-linux-x86-64.so.2’s case, that’s normal, because that’s the interpreter. In libm’s case, that usually results from an unconditional -lm, without corresponding linker options to drop unused libraries.

In many cases this results from the limited granularity of build tools; in particular, linking e.g. GNOME libraries tends to result in long lists of libraries, which aren’t always all needed as direct dependencies (but end up in the tree of library dependencies anyway). It’s usually better to try to avoid having unused dependencies, to simplify dependency processing (both by the runtime linker, and by package management tools). It’s safe to ignore libm though since that’s tied to libc anyway.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.