linking GSL library

Feb 11, 2008 at 5:45am
hi.
i'm pretty much a novice in dealing with UNIX systems, and am currently having a trouble using a library that i downloaded. Without going into the detail of my actual code, the problem i'm faced with is that i just don't know how to link the library that i downloaded to the source code.

is there anybody to enlighten me?
any help would be really appreciated. Thanks in advance.
Feb 13, 2008 at 5:49pm
you need to

A) have gsl installed properly (this should be covered at their web site)
B) pass to g++ a reference to the lib directory where the gsl libraries are located (probably something like /usr/lib or /usr/local/lib, these should both be default locations for the linker to search), and also to where the header files are, and also tell the linker to do the linking.
 
g++ -o <name of executable> -L/path/to/gsl/libs -I/path/to/headers -lgsl <name of source file>


the -L tells it where to find the libraries (.so files on linux, .dylib on OS X), -I tells it where to find the headers, -l (that's a lower case L) tells it to link to the library, which would be named libgsl.so or libgsl.dylib.

First just try adding the -lgsl flag, then if it can't find libgsl.so (or .dylib), add the -L flag. NOTE: /path/to/gsl/libs and /path/to/headers are not what you should literally put in there, but replace them with the actual paths on your system.


Topic archived. No new replies allowed.