rlinuxyuminstall.packages

cannot install R tseries, quadprog ,xts packages in Linux


I am using R version 3.4.0

I'm trying to install tseries package on linux machine:

install.packages('https://cran.cnr.berkeley.edu/src/contrib/tseries_0.10-42.tar.gz',dependencies = TRUE,repos = NULL,type ="source")

It gives error:
ERROR: compilation failed for package 'xts'
* removing '/usr/lib64/R/library/xts'
ERROR: dependency 'xts' is not available for package 'TTR'
* removing '/usr/lib64/R/library/TTR'
ERROR: dependencies 'xts', 'TTR' are not available for package 'quantmod'
* removing '/usr/lib64/R/library/quantmod'
ERROR: dependencies 'quadprog', 'quantmod' are not available for package 'tseries'
* removing '/usr/lib64/R/library/tseries'

1: In install.packages("tseries", dependencies = TRUE) :
  installation of package 'quadprog' had non-zero exit status
2: In install.packages("tseries", dependencies = TRUE) :
  installation of package 'xts' had non-zero exit status
3: In install.packages("tseries", dependencies = TRUE) :
  installation of package 'TTR' had non-zero exit status
4: In install.packages("tseries", dependencies = TRUE) :
  installation of package 'quantmod' had non-zero exit status
5: In install.packages("tseries", dependencies = TRUE) :
  installation of package 'tseries' had non-zero exit status

Then I tried installing quadprog using:

install.packages('https://cran.cnr.berkeley.edu/src/contrib/quadprog_1.5-5.tar.gz',dependencies = TRUE,repos = NULL,type ="source")

It gives error :

/usr/bin/ld: cannot find -lgfortran
collect2: error: ld returned 1 exit status
make: *** [quadprog.so] Error 1
ERROR: compilation failed for package 'quadprog'
* removing '/usr/lib64/R/library/quadprog'

Please help what should i do. I'm facing hard time in installing these packages.

I have installed R using :

sudo yum -y install R-core R-devel

I tried installing gfortran using : yum install gcc-gfortran

It says :Package gcc-gfortran-4.4.7-18.el6.x86_64 already installed and latest version Nothing to do


Solution

  • The problem here is that the Fortran compiler (gfortran) and the GCC compiler driver (gcc) are out of sync: gfortran is version 4.4.7, gcc is version 4.7.2. This means that they use different directories to store there files, and gcc is unable to locate the libgfortran.so symbolic link installed by the gcc-gfortran package.

    The solution is to bring these two compilers to the same version. This can be achieved by adjusting the PATH variable (based on other discussions, gcc is not referring to /usr/bin/gcc here), deinstalling the software collection that provides this gcc command (using yum remove devtoolset-1.1-gcc), or installing the Fortran component for the same software collection, using yum install devtoolset-1.1-gcc-gfortran.

    My best guess is that your devtoolset-1.1-gcc package comes from this repository:

    So you could use the gfortran package from there, too (and pick the c++ package as well, to avoid a similar problem).