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 a
-Wl,-rpath,~/deps/A/lib:~/deps/B/lib:~/dev/MyApp/bin
This linker option is responsible for saving the path inside the library. You need somehow to remove this.
See with ./configure --help
if there's some option that could influence this. Another option is to edit manually the makefile and remove this option.
== edit2 == One more thing
-L~/deps/A/lib -L~/deps/B/lib ~/deps/A/lib/libA.so ~/deps/B/lib/libB.so
If libA.so and libB.so don't have SONAME
, linking them like "~/deps/A/lib/libA.so" will also cause saving the path. Soname is set using -Wl,-soname,
linker option when building shared library.
If soname is set in the shared library, linking it using "~/deps/A/lib/libA.so
" form is ok.
Like Jan mentioned in the comments, the better way is using "-Llibrary/path -llibrary_name
" without rpath
.
-L~/deps/A/lib -L~/deps/B/lib -lA -lB