I am having trouble installing the GSL libraries through terminal, I found some command line options such as

sudo apt-get install libgsl0ldbl

but this did not work and I got errors that there are no installation packages found.

How do I go about fixing this and installing gsl through using the command line?


3 Answers 3



sudo apt-get install libgsl-dev

It should work on Ubuntu 18.04 as well.

  • 2
    Worked for me on Ubuntu 20.04 and allowed me to install the R package Rfast. Jul 4, 2020 at 15:47
  • Still work on Ubuntu 22.04 (necessary for package MVN)
    – user185366
    Jun 8 at 6:47

There is no quick terminal method to install gsl. The best tutorial for installation I've found is here:


Once you have done all the steps in the tutorial it would be nice to not have to type -L/home/... and -I/home/user/.... There are a few ways to do this, one way is to make an alias for gcc but I wouldn't recommend it.

I think the best way is to move the include files and the lib files to their appropriate directories. To move the include files type:

sudo cp -r /home/yourname/gsl/include/gsl/ /usr/include/

where "yourname" is the name you used for the install (the one in the tutorial).

To move the library files I used:

sudo cp /home/yourname/gsl/lib/libgsl* /usr/lib/
sudo cp /home/yourname/gsl/lib/pkgconfig/gsl.pc /usr/lib/pkgconfig/

This should work on most ubuntu installations (at least it worked on my 16.04 64 bit installation) and you should be able to compile without the use of the I and L flags.

Update : Ever since ubuntu 18.04, more modern versions of GSL are installed using the default command:

sudo apt-get install libgsl-dev

Once you do this you can run your program with:

g++ -std=c++1X <your_program>.cpp -o <output_name> -lgsl -lgslcblas -lm
  • 1
    This should be the accepted answer.
    – Astrid
    May 22, 2018 at 9:29

Type sudo apt install libgsl and press tab twice. This should print out all available packages starting with 'libgsl'. Then end the command with the one ending with a number which is in my case libgsl23, but if you use an older version of Ubuntu than 18.04 then you might have it end with a smaller number.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .