[ACCEPTED]-How to link to a shared library without lib* prefix in a different directory?-shared-libraries
Assuming an ELF platform, if you can rebuild 5
- the best fix is to simply name it
- the 4 next best fix is to set
SONAME on it:
gcc -Wl,-soname,foo.so -o foo.so foo.o
when you 3 later link with:
gcc -o a.out a.o /path/to/foo.so
SONAME will be recorded 2 as a dependency, not a full
If you can't 1 rebuild
foo.so, then do this:
rm -f foo.so && ln -s /path/to/foo.so foo.so && gcc -o a.out a.o ./foo.so && rm -f foo.so
-Wl,-rpath,. --> to use current directory 5 for searching lib files. (even if not found 4 in compilation, ok at run-time) instead 3 of -llibrary --> use library.so.
This seems 2 to work correctly. Hope anyone finds this 1 useful.
More Related questions