2

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

Ashag
  • 837
  • 2
  • 15
  • 24
  • Just *read* the error message: `cannot find -lgfortran`. So install a Fortran compiler, presumably `gfortran` of the same release as your `gcc` and `g++` binaries. – Dirk Eddelbuettel Jul 25 '17 at 01:26
  • How to install it, please tell. I have gcc (GCC) 4.7.2 20121015 (Red Hat 4.7.2-5) – Ashag Jul 25 '17 at 01:27
  • Please check edits. I tried installing gfortran – Ashag Jul 25 '17 at 01:31
  • So you have the Fortran compiler. You still need the Fortran `-dev` package providing the Fortran library you failed to link against. I do not know what RedHat/CentOS call that -- under Debian it would be `libgfortran-6-dev` for `gcc-6` etc pp. – Dirk Eddelbuettel Jul 25 '17 at 01:44
  • Please help me to find it for RedHat/CentOS. I couldnt find it – Ashag Jul 25 '17 at 01:54

4 Answers4

3

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).

Florian Weimer
  • 32,022
  • 3
  • 48
  • 92
  • Let say I do not want to deinstall and use the PATH variable to fix this issue? How do i do it? – Ashag Jul 25 '17 at 08:36
  • You need to find out where `devtoolset-1.1-gcc` came from and install devtoolset-1.1-gcc-gfortran from the same source. – Florian Weimer Jul 25 '17 at 08:39
  • `rpm -qi devtoolset-1.1-gcc` might tell you who build this package. – Florian Weimer Jul 25 '17 at 08:41
  • I think it's coming from yum -y install centos6.iuscommunity.org/… \ && yum -y install python36u \ && yum -y install python36u-devel \ && yum -y install python36u-pip \ && yum -y install python36u-tkinter.x86_64 – Ashag Jul 25 '17 at 09:18
  • Can you tell how do i install devtoolset-1.1-gcc-gfortran from the same source? – Ashag Jul 25 '17 at 09:19
  • I don't see any `devtoolset-1.1-gcc` package in the `centos6.iuscommunity.org` default repository. Does `yum info devtoolset-1.1-gcc` show any installation source? – Florian Weimer Jul 25 '17 at 09:27
  • Let me check wait – Ashag Jul 25 '17 at 09:28
  • check our chat, i have added the results – Ashag Jul 25 '17 at 09:33
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/150067/discussion-between-ashag-and-florian-weimer). – Ashag Jul 25 '17 at 09:34
2

After spending quite some time with the same error, the only solution that worked for me was to re-install all R components.

For completness, what I did was to remove all R components with: dpkg -l | grep ^ii | awk '$2 ~ /^r-/ { print $2 }' | sudo xargs apt-get remove --purge -y (got it from here)

and re-install R again: sudo apt-get install r-base r-base-dev

jsga
  • 156
  • 1
  • 5
0

I fixed this by reinstalling R from source using:

make install rhome=/usr
Comm4nd0
  • 631
  • 8
  • 14
0

I also could not install quadprog on Ubuntu due to a compilation error. Running sudo apt install zlib1g-dev and restarting R solved the problem.