Main navigation

How to use the GNU Scientific Library

Installed location: /u/local/apps/gsl/current

How to run GSL from a C program

In your program include the appropriate GSL header files as follows:

#include <gsl/gsl_include.h>

  • Replace gsl_include.h with the name of a GSL header file.
  • Call the GSL functions.

To compile and link, enter:

CC pgm.c -I$GSL_HOME/include -L$GSL_HOME/lib -lgsl -lgslcblas -lm [-static] -o pgm

  • Replace CC with either gcc or icc depending on which compiler you want to use.
  • Replace pgm.c with the name of the file containing your source code
  • Replace pgm with the name of the executable to be created.
  • Set GSL_HOME to /u/local/apps/gsl/current

If you omit -static, you will have to set the LD_LIBRARY_PATH environment variable at run time to include $GSL_HOME/lib.

Either set environment variable GSL_HOME to /u/local/apps/gsl/current or replace $GSL_HOME with /u/local/apps/gsl/current in the command shown above.

How to run GSL from a Fortran program

GSL is not available from Fortran.

Report Typos and Errors
UCLA OIT

© 2016 UC REGENTS TERMS OF USE & PRIVACY POLICY