I have my soft.c and I compile it successfully and link it against /usr/lib/myLib.so.
Everything it’s ok except for the fact that it’s not what I’m looking for, i would like to manage the final path considered for the linking, in other words i want GCC to consider the library /usr/lib/myLib.so but I also want the final linking to be a relative path, kinda like ../myLib.so.
The usual scenario is
./soft linked to -> /usr/lib/myLib.so
I want
./soft linked to -> ../myLib.so
Obiviously I also need GCC to manage any cross referenced library, for example if /usr/lib/myLib.so is linked to other libs i want all the libraries involved to be relocated in the relative path so ../myLib.so can fully work from a relative path .
How to achieve that ?
Thanks.
You could include run-time search path information in the binaries, using the
-rpathoption to the linker (passed to gcc as-Wl,-rpath,.Note that this is generally frowned upon by distribution maintainers, as there should be a single system-wide library search path so conflicts are caught early.