How to link to a shared library without lib* prefix in a different directory? [duplicate]
问题 This question already has answers here : How to link using GCC without -l nor hardcoding path for a library that does not follow the libNAME.so naming convention? (3 answers) Closed 9 months ago . I have to link my code to a shared library without the lib prefix. (say, foo.so) The first problem is -l option does not find the file. So I tried directly including this file to the last compilation like this: gcc a a.o /PATH/TO/FOO/foo.so But in this case, a is hard linked to foo.so as an absolute