6

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?

5

Try:

sudo apt-get install libgsl-dev

It should work on Ubuntu 18.04 as well.

1

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
  • This should be the accepted answer. – Astrid May 22 '18 at 9:29
0

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.