You are here



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.  See the Software Versions tab for a list of the specific versions available on various WestGrid systems.

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 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 \

Using GSL on Breezy

Set up is similar to that described for Hermes/Nestor, 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 described in the example above.

Using GSL on Lattice and Parallel

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

export GSL_HOME=/global/software/gsl/gsl116_intel

That version of the library was compiled with the Intel 12.1 icc compiler.

Using GSL on Orcinus

To set up the environment to use GSL on Orcinus, use

module load gcc/4.4.7/gsl-1.16

For More Information

2014-04-30 - Added Orcinus section.
2014-11-25 - Added Lattice/Parallel section.