Package install error: compilation failed

十年热恋 提交于 2019-12-07 03:21:05

问题


I recently updated R to 3.1.0. I tried to move my packages over to 3.1 inside the R.Framework (I'm running OSX Mavericks) and somehow made a mess of it, so did a complete uninstall of everything before a clean install.

When reinstalling packages I had no issues until I hit the forecast package which yields the following error:

     package ‘forecast’ is available as a source package but not as a binary

Warning in install.packages :
package ‘forecast’ is not available (for R version 3.1.0)

I actually had R 3.1.0 and both forecast and hts working together prior to the reinstall so I suspect the problem stems from something I've done, rather than a compatibility problem.

I ran the following to see if I could unearth some more details about the install fail: install.packages("forecast", type = "source", verbose = T, quiet = F)

The output of which is a little beyond me, but may be of help in diagnosis:

system (cmd0): /Library/Frameworks/R.framework/Resources/bin/R CMD INSTALL
trying URL 'http://cran.rstudio.com/src/contrib/forecast_5.3.tar.gz'
Content type 'application/x-gzip' length 150395 bytes (146 Kb)
opened URL
==================================================
downloaded 146 Kb

foundpkgs: forecast, /var/folders/0y/_13fkvws0tn5xh4m8wsymkdh0000gp/T//RtmpzTzSpG/downloaded_packages/forecast_5.3.tar.gz
files: /var/folders/0y/_13fkvws0tn5xh4m8wsymkdh0000gp/T//RtmpzTzSpG/downloaded_packages/forecast_5.3.tar.gz
* installing *source* package ‘forecast’ ...
** package ‘forecast’ successfully unpacked and MD5 sums checked
** libs
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include"   -fPIC  -Wall -mtune=core2 -g -O2  -c calcBATS.cpp -o calcBATS.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include"   -fPIC  -Wall -mtune=core2 -g -O2  -c calcTBATS.cpp -o calcTBATS.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include"   -fPIC  -Wall -mtune=core2 -g -O2  -c etsTargetFunction.cpp -o etsTargetFunction.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include"   -fPIC  -Wall -mtune=core2 -g -O2  -c etsTargetFunctionWrapper.cpp -o etsTargetFunctionWrapper.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include"   -fPIC  -Wall -mtune=core2 -g -O2  -c etscalc.c -o etscalc.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include"   -fPIC  -Wall -mtune=core2 -g -O2  -c etspolyroot.c -o etspolyroot.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include"   -fPIC  -Wall -mtune=core2 -g -O2  -c makeBATSMatrices.cpp -o makeBATSMatrices.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include"   -fPIC  -Wall -mtune=core2 -g -O2  -c makeTBATSMatrices.cpp -o makeTBATSMatrices.o
makeTBATSMatrices.cpp:11:6: warning: unused variable 'lengthSeasonal' [-Wunused-variable]
        int lengthSeasonal = 0;
            ^
1 warning generated.
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include"   -fPIC  -Wall -mtune=core2 -g -O2  -c updateMatrices.cpp -o updateMatrices.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include"   -fPIC  -Wall -mtune=core2 -g -O2  -c updateTBATSMatrices.cpp -o updateTBATSMatrices.o
updateTBATSMatrices.cpp:38:10: warning: unused variable 'gammaVector' [-Wunused-variable]
        double *gammaVector;
                ^
1 warning generated.
clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o forecast.so calcBATS.o calcTBATS.o etsTargetFunction.o etsTargetFunctionWrapper.o etscalc.o etspolyroot.o makeBATSMatrices.o makeTBATSMatrices.o updateMatrices.o updateTBATSMatrices.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2 -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [forecast.so] Error 1
ERROR: compilation failed for package ‘forecast’
* removing ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library/forecast’
Warning in install.packages :
  installation of package ‘forecast’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/0y/_13fkvws0tn5xh4m8wsymkdh0000gp/T/RtmpzTzSpG/downloaded_packages’

I'd really appreciate some help here. Much of the code I've been working on lately relies on functions in forecast.


回答1:


Here is what I did (RcppArmadillo Compile Errors on OS X Mavericks)

  1. Install gfortran from brew (if you don't have brew, Google it. Installation is straightforward):

    brew install gfortran

    If it's installed, upgrade to latest with:

    brew upgrade gfortran

  2. Then do one of the following:

    ln -s /usr/local/Cellar/gfortran/4.8.2/gfortran/lib/libgfortran.* /usr/local/lib/

    or add this line to the ~/.R/Makevars file:

    FLIBS=-L/usr/local/Cellar/gfortran/4.8.2/gfortran

    I did the second option.

  3. Now run install.packages("forecast", type = "source") again and it should work.




回答2:


In my case, I was trying to install the latest version of {forecast} package with devtools::install_github("robjhyndman/forecast") and had the similar error.

Then, although I am not sure if what I did is right, following mchangun's answer I did as follows and the error was resolved:

  1. brew upgrade gcc

Error: gcc 5.2.0 already installed

  1. gcc --version

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1 Apple LLVM version 7.0.0 (clang-700.1.76) Target: x86_64-apple-darwin15.0.0 Thread model: posix

  1. ls /usr/local/Cellar/gcc

4.9.2 4.9.2_1 5.2.0

  1. Add the line FLIBS=-L/usr/local/Cellar/gcc/5.2.0 to the ~/.R/Makevars file

  2. Run devtools::install_github("robjhyndman/forecast") and it worked.




回答3:


Terminal

  1. brew install gcc
  2. gcc --version
  3. ls /usr/local/Cellar/gcc 6.3.0_1
  4. sudo vi /Library/Frameworks/R.framework/Resources/etc/Makeconf
  5. Add the line FLIBS=-L/usr/local/Cellar/gcc/6.3.0_1

Rstudio:

  1. install.packages("forecast"



回答4:


Download gfortran from https://gcc.gnu.org/wiki/GFortranBinariesMacOS

sudo rm -r /usr/local/gfortran /usr/local/bin/gfortran

Then install gfortran

sudo vi /Library/Frameworks/R.framework/Resources/etc/Makeconf

change all gfortran-4.8 to gfortran

FC = gfortran FCFLAGS = -Wall -g -O2 $(LTO) FCLIBS = F77 = gfortran F77_VISIBILITY = FFLAGS = -g -O2 $(LTO)

FLIBS = -L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2 -lgfortran -lquadmath -lm

change above FLIBS to the below

FLIBS = -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm



来源:https://stackoverflow.com/questions/23135703/package-install-error-compilation-failed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!