Installing GSL libraries in Ubuntu 16.04 via terminal
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?
Try:
sudo apt-get install libgsl-dev
It should work on Ubuntu 18.04 as well.
There is no quick terminal method to install gsl. The best tutorial for installation I've found is here:
https://coral.ise.lehigh.edu/jild13/2016/07/11/hello/
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