Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing R gsl package on Ubuntu

Tags:

linux

r

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!

like image 710
nandaloo Avatar asked Oct 15 '21 10:10

nandaloo


1 Answers

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.

like image 162
Thomas G. Stewart Avatar answered Sep 23 '22 08:09

Thomas G. Stewart