This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Linking a shared library
- From: Edward Diener <eldlistmailingz at tropicsoft dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 1 Jun 2018 18:37:08 -0400
- Subject: Linking a shared library
An executable I am creating needs to link and run with a shared library
called, let's say, 'libmyshare.so' in a relative directory called, let's
say 'mylibs/lib'.
Does using the -L option while compiling the source files to object
files add the relative directory 'mylibs/lib' to the library search path
for shared libraries when linking ?
Do I specify the shared library to the linker as '-lmyshare' when
linking or do I rather specify the shared library simply as
'libmyshare.so' when linking ?
I have tried using '-Lmylibs/lib' when compiling and '-lmyshare' when
linking but the linker fails with the message:
/usr/bin/ld: cannot find -lmyshare
so I am doing something wrong and do not know what it is.