0

I run the following command (Ubuntu 18.04)

ld -L/mcr/lib -lmat --verbose

where /mcr/lib contains libmat.so. I get the following output (truncated):

...
libz.so.1 needed by /mcr/lib/libmx.so
attempt to open /mcr/lib/libz.so.1 failed
attempt to open /mcr/lib/../../sys/os/glnxa64/libz.so.1 failed
attempt to open //usr/lib/x86_64-linux-gnu/libfakeroot/libz.so.1 failed
attempt to open //usr/local/lib/libz.so.1 failed
attempt to open //usr/local/lib/x86_64-linux-gnu/libz.so.1 failed
found libz.so.1 at //lib/x86_64-linux-gnu/libz.so.1
libaudit.so.1 needed by //lib/x86_64-linux-gnu/libpam.so.0
attempt to open //usr/lib/x86_64-linux-gnu/libfakeroot/libaudit.so.1 failed
attempt to open //usr/local/lib/libaudit.so.1 failed
attempt to open //usr/local/lib/x86_64-linux-gnu/libaudit.so.1 failed
found libaudit.so.1 at //lib/x86_64-linux-gnu/libaudit.so.1
libboost_chrono.so.1.56.0 needed by /mcr/lib/libboost_log.so.1.56.0
attempt to open //usr/lib/x86_64-linux-gnu/libfakeroot/libboost_chrono.so.1.56.0 failed
attempt to open //usr/local/lib/libboost_chrono.so.1.56.0 failed
attempt to open //usr/local/lib/x86_64-linux-gnu/libboost_chrono.so.1.56.0     failed
attempt to open //lib/x86_64-linux-gnu/libboost_chrono.so.1.56.0 failed
attempt to open //usr/lib/x86_64-linux-gnu/libboost_chrono.so.1.56.0 failed
attempt to open //lib32/libboost_chrono.so.1.56.0 failed
attempt to open //usr/lib32/libboost_chrono.so.1.56.0 failed
attempt to open //usr/local/lib/x86_64-linux-gnu/libboost_chrono.so.1.56.0 failed
attempt to open //lib/x86_64-linux-gnu/libboost_chrono.so.1.56.0 failed
attempt to open //usr/lib/x86_64-linux-gnu/libboost_chrono.so.1.56.0 failed
attempt to open //usr/lib/x86_64-linux-gnu64/libboost_chrono.so.1.56.0     failed
attempt to open //usr/local/lib64/libboost_chrono.so.1.56.0 failed
attempt to open //lib64/libboost_chrono.so.1.56.0 failed
attempt to open //usr/lib64/libboost_chrono.so.1.56.0 failed
attempt to open //usr/local/lib/libboost_chrono.so.1.56.0 failed
attempt to open //lib/libboost_chrono.so.1.56.0 failed
attempt to open //usr/lib/libboost_chrono.so.1.56.0 failed
attempt to open //usr/x86_64-linux-gnu/lib64/libboost_chrono.so.1.56.0     failed
attempt to open //usr/x86_64-linux-gnu/lib/libboost_chrono.so.1.56.0 failed
attempt to open //usr/lib/x86_64-linux-    gnu/libfakeroot/libboost_chrono.so.1.56.0 failed
attempt to open //usr/local/lib/libboost_chrono.so.1.56.0 failed
attempt to open //usr/local/lib/x86_64-linux-gnu/libboost_chrono.so.1.56.0     failed
attempt to open //lib/x86_64-linux-gnu/libboost_chrono.so.1.56.0 failed
attempt to open //usr/lib/x86_64-linux-gnu/libboost_chrono.so.1.56.0 failed
attempt to open //lib32/libboost_chrono.so.1.56.0 failed
attempt to open //usr/lib32/libboost_chrono.so.1.56.0 failed
attempt to open //usr/local/lib/x86_64-linux-gnu/libboost_chrono.so.1.56.0     failed
attempt to open //lib/x86_64-linux-gnu/libboost_chrono.so.1.56.0 failed
attempt to open //usr/lib/x86_64-linux-gnu/libboost_chrono.so.1.56.0 failed
attempt to open //usr/lib/x86_64-linux-gnu64/libboost_chrono.so.1.56.0     failed
attempt to open //usr/local/lib64/libboost_chrono.so.1.56.0 failed
attempt to open //lib64/libboost_chrono.so.1.56.0 failed
attempt to open //usr/lib64/libboost_chrono.so.1.56.0 failed
attempt to open //usr/local/lib/libboost_chrono.so.1.56.0 failed
attempt to open //lib/libboost_chrono.so.1.56.0 failed
attempt to open //usr/lib/libboost_chrono.so.1.56.0 failed
attempt to open //usr/x86_64-linux-gnu/lib64/libboost_chrono.so.1.56.0     failed
attempt to open //usr/x86_64-linux-gnu/lib/libboost_chrono.so.1.56.0 failed
ld: warning: libboost_chrono.so.1.56.0, needed by     /mcr/lib/libboost_log.so.1.56.0, not found (try using -rpath or -rpath-link)
...

Now, I know that libboost_chrono.so.1.56.0 exists in /mcr/lib/ since

find /mcr/lib/libboost_chrono.so.1.56.0
/mcr/lib/libboost_chrono.so.1.56.0

What I don't get is why ld stops searching for libraries in the path specificed (-L/mcr/lib) at some point. As you can see, it does search in the given path at the start but then just stops.

Any help appreciated!

VGD
  • 436
  • 1
  • 5
  • 25
  • Contemplate the warning message. *try using -rpath or -rpath-link*. The linker is literally telling you what to do. – n. m. could be an AI Sep 12 '19 at 12:45
  • [Possible duplicate](https://stackoverflow.com/questions/8482152/whats-the-difference-between-rpath-and-l). – n. m. could be an AI Sep 12 '19 at 12:50
  • I looked at this post (https://stackoverflow.com/questions/8482152/whats-the-difference-between-rpath-and-l), the way I interpreted it -L is the one important for linking and also the one ld uses; even if it works with -rpath, I would like to know why it stops searching in the specificed path – VGD Sep 12 '19 at 12:52
  • 1
    This path is tto find libraries the linker *links*. It is not to find their *runtime dependencies*. – n. m. could be an AI Sep 12 '19 at 12:55
  • ah okay. So the linker only looks for libraries specified with -l in the -L directories, and any libraries that those -l libraries depend on do not get searched for in the -L directories? – VGD Sep 12 '19 at 13:04
  • That's correct (these libraries serve different purposes). – n. m. could be an AI Sep 12 '19 at 13:58

0 Answers0