Skip to content

GSL

The GNU Scientific Library (GSL) is a powerful library of common numerical and scientific functions intended for use in C and C++ software. It serves as an important backend in many software packages.


GSL requires an environment module

In order to use GSL, you must first load the appropriate environment module:

module load gnu

The GNU Scientific Library (GSL) is a powerful library of numerical functions that are commonly used in Scientific software. The library supports linking with C and C++ code. GSL commonly gets used as a backend for larger scientific software packages. There is an R library which wraps GSL for use in R as well R GSL which is a dependency of many other R libraries.

Versions of GSL Available on RCC Systems#

The HPC has three versions of GSL available. The versions are listed below in the following table. with the current default version being 1.6:

Version Environment Module Full File Path
1.6 gnu /usr/lib64/
2.3 gnu gsl/2.3 /gpfs/research/software/gsl/2.3/gsl-2.3_build/
2.6 gnu gsl/2.6 /gpfs/research/software/gsl/2.6/gsl-2.6_build/

Using GSL on RCC Systems#

Note

Check your package's documentation and recommended installation method before proceeding.

To use the default version of GSL on RCC systems, you should include it in your code according to the documentation example from the official website.

Then you will need to complete two steps to compiler your program and link it correctly to the default GSL library:

1
2
3
# Replace MYPROGRAMNAME with the appropriate name of your source code file
gcc -I/usr/include/gsl/ -c MYPROGRAMNAME.c
gcc -L/usr/lib64/ MYPROGRAMNAME.o -lgsl -lgslcblas -lm

Linking against Newer GSL Versions#

Linking against the newer versions of GSL is possible in much the same way. Start by including GSL in your code. Then you will need to complete two steps to get your program compiled and linked correctly to the default GSL library:

Using GSL Version 2.3#

1
2
3
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/gpfs/research/software/gsl/2.3/gsl-2.3_build/lib/
$ gcc -I/gpfs/research/software/gsl/2.3/gsl-2.3_build/include/ -c MYPROGRAMNAME.c
$ gcc -L/gpfs/research/software/gsl/2.3/gsl-2.3_build/lib/ MYPROGRAMNAME.o -lgsl -lgslcblas -lm

Using GSL Version 2.6#

1
2
3
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/gpfs/research/software/gsl/2.6/gsl-2.6_build/lib/
$ gcc -I/gpfs/research/software/gsl/2.6/gsl-2.6_build/include/ -c MYPROGRAMNAME.c
$ gcc -L/gpfs/research/software/gsl/2.6/gsl-2.6_build/lib/ MYPROGRAMNAME.o -lgsl -lgslcblas -lm

Using Newer GSL Versions for R Library Installations#

One situation which can arise is that you may wish to install an R library which depends on a newer version of GSL.

There are many possible ways that you can accomplish this, and you should refer to your package's documentation. One example of a possible installation route is as follows. Note that the environment variables your package uses to access the GSL library and configuration programs may be different.

1
2
3
install.packages("MYLIBRARYNAME", \
configure.vars=c("GSL_CONFIG=/gpfs/research/software/gsl/2.6/gsl-2.6_build/bin/gsl-config", \
"GSL_LIBS=/gpfs/research/software/gsl/2.6/gsl-2.6_build/lib")