[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
2.2.1 Linking programs with the library
The library is installed as a single file, ‘libgsl.a’. A shared version of the library ‘libgsl.so’ is also installed on systems that support shared libraries. The default location of these files is ‘/usr/local/lib’. If this directory is not on the standard search path of your linker you will also need to provide its location as a command line flag.
To link against the library you need to specify both the main library and a supporting CBLAS library, which provides standard basic linear algebra subroutines. A suitable CBLAS implementation is provided in the library ‘libgslcblas.a’ if your system does not provide one. The following example shows how to link an application with the library,
$ gcc -L/usr/local/lib example.o -lgsl -lgslcblas -lm |
The default library path for gcc
searches ‘/usr/local/lib’
automatically so the -L
option can be omitted when GSL is
installed in its default location.