This is a quote from Linux programming book:
% gcc -o app app.o -L. –ltest
Suppose that both libtest.
libtest.
You could use -l option in its form -l:filename if your linker supports it (older versions of ld didn't)
-l
-l:filename
ld
gcc -o app app.o -L. -l:libtest.so
Other option is to use the filename directly without -l and -L
-L
gcc -o app app.o /path/to/library/libtest.so