I have a number of executables which link against a single lib path. For instance, the executable foo
links against (say) libboost_system.so
and libfoo.so
, the latter of which I build myself. I place third party libraries in a variable LDLIBS
, and link my library via -lfoo
, so that the makefile line looks as follows:
foo: objects
$(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS) -lfoo
However, when I readelf
, I see my own path!
$ readelf --dynamic foo
Dynamic section at offset 0x3c68 contains 48 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [/home/username/foo_dir/lib/libfoo.so]
0x0000000000000001 (NEEDED) Shared library: [libboost_system.so.1.58.0]
My own library is the only library which has an absolute path in it.
How can I get rid of this monstrosity using only the makefile, i.e., without using patchelf --replace-needed
or chrpath
?