Package install error: compilation failed

。_饼干妹妹 提交于 2019-12-05 07:22:22
mchangun

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.

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.

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"

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

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