Reputation: 137
Is it possible to make g++/ld show the absolute path of the library, that a -l option has been resolved to? In my case I am trying to link the lrs library through -llrs and I suspect that it resolves to /usr/lib/liblrs.so but I want to be sure.
Upvotes: -1
Views: 735
Reputation: 400
ELF files do not include an absolute path to the shared library. That is the job of the dynamic linker. You can confirm this by running. strings executable | grep libname. The shared library can be anywhere on the linker search path.
readelf -d executable
To test the behaviour of the dynamic loader use ldd (List Dynamic Dependencies)
Example below with /bin/bash
ldd /bin/bash
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
You may also want to follow symlinks
ls -al /lib/x86_64-linux-gnu/libc.so.6
lrwxrwxrwx 1 root root 12 Feb 5 2019 /lib/x86_64-linux-gnu/libc.so.6 -> libc-2.23.so
Upvotes: 1