LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   How to link a lib? (http://www.linuxquestions.org/questions/programming-9/how-to-link-a-lib-229074/)

theonebeyond 09-10-2004 04:27 PM

How to link a lib?
 
Hi there!

I've got a little question about something really essential... nOObiE - Question

When I want to use a library... delivered with a programm (in my case this is a lib delivered with gpsd)... how do I do this exactly?

I have a file ... the lib itself... where do I have to put it? Is it enough put put it into the compiling directory?

And then I habe to link against it in some way... or not?

Thanks a lot,.. greetings, Sascha

leonscape 09-10-2004 04:36 PM

A .so file ( the library itself ) is usually in /usr/lib, to link your program to it you pass options on the command line when compiling you have to pass a library path with -L and the actual lib with -l without the .so extension.

-L /usr/lib -lthelib

theonebeyond 09-11-2004 02:22 AM

Ok,.. that sou8nds easy...

How about placing the lib in the directory, in which I compile to prgramm? Is that possible? If so, I think I can let the -L /path/to/lib/ away?

Thanks very much!

GReetings, Sascha

Cedrik 09-11-2004 03:10 AM

It is possible, just make sure the lib file is not a symlink. But I think you will need the -l option though.


All times are GMT -5. The time now is 01:39 PM.