I have an executable that links against a dynamic library (called libester_timing.so
), which in turn links against another shared library (libester_patternset.so
). Yet my executable only uses parts of libester_timing.so
, which do not rely on libester_patternset.so
. Thus, libester_patternset.so
is not part of the NEEDED section in the ELF dynamic section of my executable:
0x0000000000000001 (NEEDED) Shared library: [libdate_tools.so]
0x0000000000000001 (NEEDED) Shared library: [libester_timing.so]
0x0000000000000001 (NEEDED) Shared library: [libester_circuit.so]
0x0000000000000001 (NEEDED) Shared library: [libester_bitlogic.so]
0x0000000000000001 (NEEDED) Shared library: [libester_utilities.so]
0x0000000000000001 (NEEDED) Shared library: [libboost_system.so.1.65.1]
0x0000000000000001 (NEEDED) Shared library: [libboost_filesystem.so.1.65.1]
0x0000000000000001 (NEEDED) Shared library: [libboost_unit_test_framework.so.1.65.1]
0x0000000000000001 (NEEDED) Shared library: [libboost_log.so.1.65.1]
0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0]
0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
Correspondingly, ldd
gives me:
libester_patternset.so => not found
Note that all libester_*
libraries are located in the same folder (which is not in LD_LIBRARY_PATH
) and for all NEEDED libraries, ldd
returns that folder correctly.
Now if I call my executable, I get the "cannot open shared object file" error. This problem vanishes if I insert code into my executable, which calls functions from the libester_patternset.so
library (even if the code is never executed).
My understanding (for now) is that the loader loads libester_timing.so
, which requires libester_patternset.so
, but now does not use the RUNPATH
(or RPATH
) of the executable anymore, but uses LD_LIBRARY_PATH
instead - indeed the problem vanishes if I modify LD_LIBRARY_PATH
correspondingly. Is that correct? How can I circumvent this problem? Both solutions (adding unnecessary code or adjusting LD_LIBRARY_PATH
) seem very "hacky" to me at best. Do I need to modify libester_timing.so
's RPATH
?