1

Why does ubuntu duplicate object files and how can I manage finding the correct file that is owned by a package without relying on hacks to alter LD_LIBRARY_PATH?

An easy example from the Ubuntu 20.04:

> docker run -it --rm ubuntu:20.04
...
# ldd /usr/bin/apt
    ...
    libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f7eded19000)
    ...
# dpkg-query --search /lib/x86_64-linux-gnu/libstdc++.so.6
dpkg-query: no path found matching pattern /lib/x86_64-linux-gnu/libstdc++.so.6
# dpkg-query --search /usr/lib/x86_64-linux-gnu/libstdc++.so.6
libstdc++6:amd64: /usr/lib/x86_64-linux-gnu/libstdc++.so.6

I am looking at object files linked to apt, and libstdc++.so.6 is one. The libstdc++6 package owns /usr/lib/x86_64-linux-gnu/libstdc++.so.6. However:

  1. the order ldd looks for the object files specifies /lib before /usr/lib
  2. the object file exists in both /lib and /usr/lib
  3. the file that is owned by the package is later in the order

This culminates in the object file being loaded not being the one owned by the package that provides the file.

I verified debian does not have duplicate object files (or at minimum, not libstdc++6). Why do they exist? Is there a way to ignore them?

  • first for compatible reasons there was a structure but now lib is just symlinked to /usr/lib – lnee Apr 01 '22 at 18:28
  • I did not even think to check if the entire dir structure was symlinked, thanks! If you put that in an answer I can mark it as accepted. Now to write a hack to deal with that knowledge... – Brandon Waskiewicz Apr 01 '22 at 18:44

1 Answers1

2

First for compatibility reasons there was a structure, but now lib is just symlinked to /usr/lib

See also

steeldriver
  • 136,215
  • 21
  • 243
  • 336
lnee
  • 806