Re: Linking a shared library

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/2/2018 1:54 AM, Marc Glisse wrote:
On Fri, 1 Jun 2018, Edward Diener wrote:

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 ?

No. Since -L tells -l where to look, why would you want to separate them into 2 separate commands? Did some documentation recommend that somewhere?

clang even gives you a warning if you pass -L to a compile (-c) command.

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 ?

-lmyshare (or you can pass /full/path/to/libmyshare.so and omit the -L option).

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.

(your next question will likely be how to tell where to find the library at runtime...)


I figured out what was wrong when linking. I had specified the symbolic link incorrectly so that the library name 'libmyshare.so' was a link which was pointing to a file that did not exist.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux