Installing GSL libraries in Ubuntu 16.04 via terminal
Matthew Martinez
I am having trouble installing the GSL libraries through terminal, I found some command line options such as
sudo apt-get install libgsl0ldblbut 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
Try:
sudo apt-get install libgsl-devIt should work on Ubuntu 18.04 as well.
1There 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-devOnce you do this you can run your program with:
g++ -std=c++1X <your_program>.cpp -o <output_name> -lgsl -lgslcblas -lm 1 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.