The rpath
of an executable specifies one or more directories wherein to look for shared objects at runtime.
My question is - do shared object files themselves also have statically-compiled rpath
s?
I recently received a runtime error when linking with a shared object:
./example: /opt/swt/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by ./mylib.so)
This error indicates to me that the actually library itself - mylib.so
, has an statically compiled rpath
.
My understanding was that rpath
only applied to executables, not shared objects. So does rpath
also apply to shared objects?
do shared object files themselves also have statically-compiled
rpaths
They may (or may not) depending on whether they were linked with -Wl,-rpath=...
option.
This error indicates to me that the actually library itself -
mylib.so
, has an statically compiledrpath
.
The error message does not say that at all. Where did you get that idea?
If you want to know whether mylib.so
has DT_RPATH
or not, do this:
readelf -d mylib.so | grep 'R.*PATH' # could also have RUNPATH
My understanding was that
rpath
only applied to executables, not shared objects. So doesrpath
also apply to shared objects?
Your understanding is incorrect, and RPATH
(and RUNPATH
) works for shared objects just as well.