Install and use GSL library

The packages for GSL can be found here
You can install just the library by using: apt-get install libgsl0ldbl

You can also install the development package and binary using: apt-get install gsl-bin libgsl0-dev

The resources/docs can also be installed using: apt-get install gsl-doc-info gsl-doc-pdf gsl-ref-html gsl-ref-psdoc

*depending on your setup you may need to use sudo before the apt-get command


Sample Codes Using GSL Routines

Directory Listings

C++ Programs

Compile and link C++ program program.cpp with: 
   g++ -Wall -c program.c
   g++ -o program program.o -lgsl -lgslcblas -lm

or all at once: 
   g++ -Wall -o program program.c -lgsl -lgslcblas -lm

file last changed
qagiu_test.cpp 12/28/2003
Monte_Carlo_test.cpp 12/28/2003
qags_test.cpp 01/19/2006
ode_test.cpp 12/28/2003
simple_function.cpp 01/03/2004
acceleration_test.cpp 12/28/2003
J0_test.cpp 12/28/2003
multifit_test.cpp 12/28/2003

C Programs

Compile and link C program program.c with: 
   gcc -Wall -c program.c
   gcc -o program program.o -lgsl -lgslcblas -lm

or all at once: 
   gcc -Wall -o program program.c -lgsl -lgslcblas -lm

file last changed
qagiu_test.c 11/19/2002
acceleration_test.c 09/27/2002
Monte_Carlo_test.c 09/27/2002
J0_test.c 09/27/2002
qags_test.c 11/19/2002
multifit_test.c 09/27/2002
ode_test.c 11/14/2002


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.

The option -lm links with the system math library. On some systems it is not needed.3

For a tutorial introduction to the GNU C Compiler and related programs, see An Introduction to GCC (ISBN 0954161793).4



你可能感兴趣的:(Install and use GSL library)