8

I am facing the following errors while trying to install the caret package in R.

     g++: error: /tmp/Rtmp2Tos7n/R.INSTALL2e6e30153a74/nloptr/nlopt-2.4.2/lib/libnlopt_cxx.a: 
No such file or directory make: *** [nloptr.so] Error 1
    
    ERROR: compilation failed for package ‘nloptr’
    * removing ‘/rmt/csfiles/pgrads/mava290/R/x86_64-suse-linux-gnu-library/3.1/nloptr’
    Warning in install.packages :
      installation of package ‘nloptr’ had non-zero exit status
    ERROR: dependency ‘nloptr’ is not available for package ‘lme4’
    * removing ‘/rmt/csfiles/pgrads/mava290/R/x86_64-suse-linux-gnu-library/3.1/lme4’
    Warning in install.packages :
      installation of package ‘lme4’ had non-zero exit status
    ERROR: dependency ‘lme4’ is not available for package ‘pbkrtest’
    * removing ‘/rmt/csfiles/pgrads/mava290/R/x86_64-suse-linux-gnu-library/3.1/pbkrtest’
    Warning in install.packages :
      installation of package ‘pbkrtest’ had non-zero exit status
    ERROR: dependency ‘lme4’ is not available for package ‘BradleyTerry2’
    * removing ‘/rmt/csfiles/pgrads/mava290/R/x86_64-suse-linux-gnu-library/3.1/BradleyTerry2’
    Warning in install.packages :
      installation of package ‘BradleyTerry2’ had non-zero exit status
    ERROR: dependency ‘pbkrtest’ is not available for package ‘car’
    * removing ‘/rmt/csfiles/pgrads/mava290/R/x86_64-suse-linux-gnu-library/3.1/car’
    Warning in install.packages :
      installation of package ‘car’ had non-zero exit status
    ERROR: dependencies ‘car’, ‘BradleyTerry2’ are not available for package ‘caret’
    * removing ‘/rmt/csfiles/pgrads/mava290/R/x86_64-suse-linux-gnu-library/3.1/caret’
    Warning in install.packages :
      installation of package ‘caret’ had non-zero exit status
    
    The downloaded source packages are in
        ‘/tmp/RtmpG9dYqn/downloaded_packages’

I looked into this other question that had a similar problem

Dependency issue while installing caret package in R

The solution for this problem was to install each of the dependencies first, but they all had the same error message. For example:

>install.packages('nloptr')

g++: error: /tmp/RtmpgEn54A/R.INSTALL7015350f0d03/nloptr/nlopt-2.4.2/lib/libnlopt_cxx.a: No such file or directory
make: *** [nloptr.so] Error 1
ERROR: compilation failed for package ‘nloptr’
* removing ‘/rmt/csfiles/pgrads/mava290/R/x86_64-suse-linux-gnu-library/3.1/nloptr’
Warning in install.packages :
  installation of package ‘nloptr’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpG9dYqn/downloaded_packages’

I also tried changing the repos ie. install.packages('caret', repos='http://cran.rstudio.com/') but it dint work either.

My session info is given below:

> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-suse-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
 [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] tools_3.1.2
Subha Yoganandan
  • 325
  • 1
  • 6
  • 13
  • Did you first install the header of nlopt library? –  Mar 11 '15 at 11:49
  • @Pascal: I tried installing it as given in this website https://r-forge.r-project.org/R/?group_id=933 by using the command `install.packages("nloptr", repos="http://R-Forge.R-project.org")`. Isn't that sufficient? I'm using linux – Subha Yoganandan Mar 11 '15 at 12:18
  • No, it is not if you didn't install the headers of nlopt library in your Linux system. –  Mar 11 '15 at 12:29
  • on my machine (Linux Debian), there is a libnopt-dev package. I believe that is what makes the compilation fail and you have to install it before installing the R package (with a package manager such as YaST, not R). – xraynaud Mar 11 '15 at 13:30
  • 2
    try sudo apt-get install r-cran-caret . That might install the dependencies for you if you can't figure out otherwise. – cory Mar 11 '15 at 15:00
  • @cory If they're using suse apt-get won't work – Dason Mar 19 '15 at 13:49

4 Answers4

2

I was hoping to add a comment first. On Jan 28, 2015, there was an addition to the nloptr package in github that possibly broke the compilation. I used a workaround by installing from an older version with the command

install.packages("http://cran.r-project.org/src/contrib/Archive/nloptr/nloptr_1.0.0.tar.gz",
                 repos=NULL, type="source")
Stibu
  • 15,166
  • 6
  • 57
  • 71
yindalon
  • 267
  • 3
  • 12
2

I recently encountered the problem with nlopt as well. It was easily solved by installing nlopt-devel and its associated dependencies from YaST (or your preferred package manager).

Rewarp
  • 220
  • 1
  • 11
0

As mentioned in this R help forum:

http://r.789695.n4.nabble.com/can-t-install-rugarch-and-nloptr-packages-in-R-3-01-opensuse-linux-td4669649.html

add the line to the src/Makevars file

     mv .libs lib; \

between

     make install; \
     ls | grep -v ^include$$ | grep -v ^lib$$ | xargs rm -rf; \

This will remove the compilation error and you would be able to install nloptr package. I have tested this for nloptr_1.0.0.tar.gz .

unrahul
  • 1,281
  • 1
  • 10
  • 21
-1

I solve this issue by installing first "car" from synaptic (use filter with "cran-car"). And then I install "caret" with rstudio but I guess it will work also for R. Hope it helps, Regards

Fad
  • 11