I need to build two 3rd party shared libraries, so their .so files will be reused by other projects. However, after build one of these libraries contains hardcoded path to another. This path is invalid on other machines and causes linker warnings. How can I prevent the full path from being embedded in the resulting .so files?
Details:
First library source: ~/dev/A
Second library source: ~/dev/B
Both of them have configure script to generate make files. Library B depends on A. So, first I build A:
$ ~/dev/A/configure --prefix=~/dev/A-install $ make && make install Then I build B:
$ ~/dev/B/configure --prefix=~/dev/B-install --with-A=~/dev/A-install $ make && make install Then I want to upload the contents of ~/dev/A-install and ~/dev/B-install to our file server, so other teams and build machines can use the binaries. But they get linker warnings when they try to use B:
/usr/bin/ld: warning: libA.so.2, needed by /.../deps/B/lib/libB.so, not found (try using -rpath or -rpath-link) When I run ldd libB.so it gives:
... libA.so.2 => /home/alex/dev/A-install/lib/libA.so.2 Obviously this path exists only on my machine and cannot be found on other machines.
How can I remove full hardcoded path from libB.so?
Thanks.
patchelfmight help you get rid of the encoded path (the RPATH).~? Why not use something like say/optas prefix which is not dependent on environment variable like$HOME(~)? You can tryLD_PRELOADmaybeconfigurescript to prevent this problem. If you want to edit the libraries, I've heard good things about elfsh (eresi-project.org).configurescript is designed to be used in this situation. Yes, it's not completely obvious from the documentation until you read it very carefully.