16

I am failing to install the R package gsl on my ubuntu 18.04 LTS, and I don't understand what the problem is.

From within R:

> install.packages('gsl')
* installing *source* package ‘gsl’ ...
** package ‘gsl’ successfully unpacked and MD5 sums checked
** using staged installation
checking for gsl-config... /usr/bin/gsl-config
checking if GSL version >= 2.1... checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
configure: error: Need GSL version >= 1.16
ERROR: configuration failed for package ‘gsl’
* removing ‘/home/luca_ph/R/lib/R/library/gsl’

It sais it needs gsl version >= 1.16, however I have it installed:

dpkg -s libgsl-dev | grep Version
Version: 2.4+dfsg-6

Also, gsl-config is available in the $PATH (as suggested here.

I tried to pass the appropiate compiler arguments to R when calling it (as suggested here), however it fails all the same:

> gsl-config --libs
-L/usr/lib/x86_64-linux-gnu -lgsl -lgslcblas -lm
> gsl-config --cflags
-I/usr/include
> CFLAGS="-I/usr/include" LDFLAGS="-L/usr/lib/x86_64-linux-gnu -lgsl -lgslcblas -lm" R
> install.packages('gsl')
[...]
* installing *source* package ‘gsl’ ...
** package ‘gsl’ successfully unpacked and MD5 sums checked
** using staged installation
checking for gsl-config... /usr/bin/gsl-config
checking if GSL version >= 2.1... checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
configure: error: Need GSL version >= 1.16
ERROR: configuration failed for package ‘gsl’

What am I missing here?

Thanks a lot!

nandaloo
  • 1,007
  • 2
  • 11
  • 16
  • Does it help to install `libgsl2` as well? – r2evans Oct 15 '21 at 11:24
  • 1
    you could try installing the binary with `apt install r-cran-gsl` (after setting up the [c2d4u ppa](https://cran.r-project.org/bin/linux/ubuntu/) – user20650 Oct 15 '21 at 12:13
  • 1
    thanks, both of you, however, it doesn't help. @r2evans No, unfortunatley not. According to `apt install libgsl2-dev` the pacakge was replaced by libgslcblas0. And libgslcblas0 is already installed... @user20650: i can install it using 'apt install r-cran-gsl', however, it just doesn't change anything to my problem... :/ – nandaloo Oct 15 '21 at 12:28
  • The presence of `GSL version >= 1.16` & `GSL version >= 2.1` suggests you have two gsl versions installed, prior to gsl 2.4 for >=1.16 requirement, so perhaps `sudo locate gsl-config` gives two paths. – Chris Oct 15 '21 at 15:08
  • @Chris no, it only gives one path... : /usr/bin/gsl-config – nandaloo Oct 18 '21 at 06:48
  • I have the same problem – thedumbkid Oct 19 '21 at 19:06

1 Answers1

14

Despite the error message, R package gsl now requires GSL version >= 2.5 (see here). Even though I was able to install the most recent version of GSL (2.7), I wasn't knowledgeable enough to follow the advice in the INSTALL file of the R package:

If the gsl R package builds successfully but will not load, make sure to inform your system linker/loader where to find the GSL libraries used to compile it. That step may be missed when using a manual GSL installation as opposed to one performed by a package manager.

So I opted to use the PPA repo linked to in the How to get GNU software webpage which had GSL version 2.5 available.

In short, I ran these commands to overcome the issue you describe:

sudo add-apt-repository ppa:dns/gnu
sudo apt-get update
sudo apt install libgsl-dev

Not 100% sure if this is generally applicable, but I also had to remove the previous version of GSL with the sudo apt remove command before installing the newer version.