The linker is able to accept filenames too
gcc app.o -l:libmy.so.1 -o app
From man ld
:
-l namespec
--library=namespec
Add the archive or object file specified by namespec to the list of files to link. This option may be used any number of times. If
namespec is of the form :filename, ld will search the library path for a file called filename, otherwise it will search the library
path for a file called libnamespec.a.
I noticed that older versions do not support it, so check man ld
-l
or --library
option on your system.
You could also link to the file mentioning its full name
gcc app.o /mylibpath/libmy.so.1 -o app
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…