[英]Package install error: compilation failed
I recently updated R to 3.1.0.我最近将 R 更新为 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.
我试图将我的包移动到 R.Framework 中的 3.1(我正在运行 OSX Mavericks)并且不知何故弄得一团糟,所以在全新安装之前完全卸载了所有内容。
When reinstalling packages I had no issues until I hit the forecast
package which yields the following error:重新安装软件包时,我没有任何问题,直到我遇到了产生以下错误的
forecast
软件包:
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.我实际上有 R 3.1.0 并且在重新安装之前预测和 hts 一起工作,所以我怀疑问题源于我所做的事情,而不是兼容性问题。
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)
我运行了以下命令以查看是否可以发现有关安装失败的更多详细信息:
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.
我最近处理的大部分代码都依赖于预测中的函数。
Here is what I did ( RcppArmadillo Compile Errors on OS X Mavericks )这是我所做的( OS X Mavericks 上的 RcppArmadillo 编译错误)
Install gfortran from brew (if you don't have brew, Google it. Installation is straightforward):从 brew 安装 gfortran(如果你没有 brew,谷歌它。安装很简单):
brew install gfortran
If it's installed, upgrade to latest with:如果已安装,请使用以下命令升级到最新版本:
brew upgrade gfortran
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:或将此行添加到
~/.R/Makevars
文件中:
FLIBS=-L/usr/local/Cellar/gfortran/4.8.2/gfortran
I did the second option.我做了第二个选择。
Now run install.packages("forecast", type = "source")
again and it should work.现在再次运行
install.packages("forecast", type = "source")
它应该可以工作。
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.就我而言,我试图用
devtools::install_github("robjhyndman/forecast")
安装最新版本的 {forecast} 包,但遇到了类似的错误。
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:然后,虽然我不确定我所做的是否正确,但按照 mchangun 的回答,我做了如下操作并解决了错误:
brew upgrade gcc
Error: gcc 5.2.0 already installed错误:gcc 5.2.0 已经安装
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配置为:--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) 目标:x86_64-apple-darwin15.0.0 线程模型:posix
ls /usr/local/Cellar/gcc
4.9.2 4.9.2_1 5.2.0 4.9.2 4.9.2_1 5.2.0
Add the line FLIBS=-L/usr/local/Cellar/gcc/5.2.0
to the ~/.R/Makevars
file将
FLIBS=-L/usr/local/Cellar/gcc/5.2.0
到~/.R/Makevars
文件
Run devtools::install_github("robjhyndman/forecast")
and it worked.运行
devtools::install_github("robjhyndman/forecast")
并且它起作用了。
Terminal终端
Rstudio:工作室:
Download gfortran from https://gcc.gnu.org/wiki/GFortranBinariesMacOS从https://gcc.gnu.org/wiki/GFortranBinariesMacOS下载 gfortran
sudo rm -r /usr/local/gfortran /usr/local/bin/gfortran须藤 rm -r /usr/local/gfortran /usr/local/bin/gfortran
Then install gfortran然后安装gfortran
sudo vi /Library/Frameworks/R.framework/Resources/etc/Makeconf须藤 vi /Library/Frameworks/R.framework/Resources/etc/Makeconf
change all gfortran-4.8 to gfortran将所有 gfortran-4.8 更改为 gfortran
FC = gfortran FCFLAGS = -Wall -g -O2 $(LTO) FCLIBS = F77 = gfortran F77_VISIBILITY = FFLAGS = -g -O2 $(LTO) FC = gfortran FCFLAGS = -Wall -g -O2 $(LTO) FCLIBS = F77 = gfortran F77_VISIBILITY = FFLAGS = -g -O2 $(LTO)
要安装 gfortran,请使用
brew cask install gfortran
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.