GSL - GNU Scientific Library


As described on the GSL home page, it is a numerical library for C and C++ programmers including numerical integration, linear algebra, minimization, special functions and other mathematical routines.

The main WestGrid software page shows the versions of GSL available on the various WestGrid computational systems.

Some brief notes on inititalizing GSL on some of those systems are shown below along with an example of compiling and linking.


Compiling and linking of GSL library routines is illustrated below using an example program from the GSL manual.  The examples are shown with the Intel icc compiler.  The GNU gcc compiler can also be used, but, for many programs icc gives better performance.

Your code can be compiled and linked to GSL library routines by including -lgsl -lgslcblas on your compiler command line. Using -lgslcblas requests the GSL implementation of CBLAS.

icc -O3 bessel.c -lgsl -lgslcblas -o bessel

On some systems, it may be convenient to use the program gsl-config to provide the include files and library locations.  Assuming gsl-config is on the command path:

icc $(gsl-config --cflags) bessel.c $(gsl-config --libs) -o bessel

To use the Intel Math Kernel Library (MKL) implementation of BLAS, instead of linking with -lgslcblas, one can use:

icc -O3 bessel.c -lgsl -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -o bessel

Using GSL on Breezy

Set up is similar to that described for Hermes/Nestor below, except

export GSL_HOME=/global/software/gsl/gsl115

Using GSL on Bugaboo

The GSL libraries are in the default search path so you should be able to compile and link the code directly as illustrated above.

Using GSL on Checkers

GSL version 1.14, compiled with gcc 4.3.2, has been installed on Checkers under /global/scratch/software/{bin,lib,include}. Those directories are in the default library and include search paths, so, you can compile and link your GSL library routines as illustrated above.

Using GSL on Hermes/Nestor

GSL version 1.14 has been installed on Hermes/Nestor under /global/software/gsl-1.14/{bin,lib,include}. Those directories are not in the default command, library and include search paths. To initialize your environment you can use (for bash shell users):

export GSL_HOME=/global/software/gsl-1.14
export CPATH=$GSL_HOME/include:$CPATH

With these environment variables set, you won't need to specify paths with -I and -L.  You can then compile and link your GSL library routines as in this example:

icc -O3 bessel.c -lgsl -lgslcblas -o bessel -shared-intel

(The -shared-intel option is not necessary, but, an unimportant warning message is suppressed by using it.)

To run the code, modify the LD_LIBRARY_PATH environment variable to include the GSL library directory:


As an alternative, you can avoid modifying environment variables by encoding all the information into the compiler command line:

icc -O3 bessel.c -o bessel \
-I/global/software/gsl-1.14/include \
-L/global/software/gsl-1.14/lib -lgsl -lgslcblas \
-shared-intel \

Updated 2011-10-12.