R 3.2、GCC 和自制软件

R 3.2, GCC, and homebrew

我最近需要安装 R 3.2 来让 Bioconductor 的软件包正常工作,但是在安装之后,我收到以下错误:

[16:16:11 20] $ r
dyld: Library not loaded: /usr/local/lib/gcc/4.9/libgfortran.3.dylib
  Referenced from: /usr/local/Cellar/r/3.2.0/R.framework/Versions/3.2/Resources/lib/libR.dylib
  Reason: image not found
Trace/BPT trap: 5

果然brew被设置为使用gcc 5,所以我告诉brew使用4.9版本

brew switch gcc 4.9

它得到了 R 运行,但是 R 会在包安装过程中失败(特别是当我 运行 biocLite('DESeq2').

从那时起,我尝试了很多事情,包括尝试安装 gcc 4.8(但我似乎无法让 R 使用它,即使通过 ~/.R/Makevars)。即使没有安装4.9,R也坚持调用如上所示的路径

R 的 windows 版本似乎说 4.9 不适用于 3.2:

R-devel temporarily used a new toolchain based on 4.9.2 gcc, put together by Duncan Murdoch using build scripts written by a contractor. However, there were too many incompatibilities with existing code, and this toolchain will not be used for R 3.2.0. See notes for details on building and testing the new toolchain.

如有任何帮助,我们将不胜感激!

编辑: 我尝试按照@lmw 的建议从源代码安装,但失败了:

[11:27:55 2] $ brew install r --build-from-source
==> Installing r from homebrew/homebrew-science
==> Installing r dependency: gcc
==> Downloading http://ftpmirror.gnu.org/gcc/gcc-5.1.0/gcc-5.1.0.tar.bz2
######################################################################## 100.0%
curl: (28) Resolving timed out after 5542 milliseconds
Trying a mirror...
==> Downloading https://ftp.gnu.org/gnu/gcc/gcc-5.1.0/gcc-5.1.0.tar.bz2
######################################################################## 100.0%
==> Patching
patching file gcc/jit/Make-lang.in
==> ../configure --build=x86_64-apple-darwin14.3.0 --prefix=/usr/local/Cellar/gcc/5.1.0 --libdir=/usr/local/Cellar/gc
==> make bootstrap
==> make install
==> Caveats
GCC has been built with multilib support. Notably, OpenMP may not work:
  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60670
If you need OpenMP support you may want to
  brew reinstall gcc --without-multilib
==> Summary
  /usr/local/Cellar/gcc/5.1.0: 1351 files, 248M, built in 32.5 minutes
==> Installing r
==> Using Homebrew-provided fortran compiler.
This may be changed by setting the FC environment variable.
==> Downloading http://cran.rstudio.com/src/base/R-3/R-3.2.0.tar.gz
######################################################################## 100.0%
==> Patching
patching file src/modules/lapack/vecLibg95c.c
==> ./configure --prefix=/usr/local/Cellar/r/3.2.0_1 --with-libintl-prefix=/usr/local/opt/gettext --enable-memory-pro
==> make
** installing vignettes
** testing if installed package can be loaded
* DONE (survival)
make[1]: *** [recommended-packages] Error 2
make: *** [stamp-recommended] Error 2

READ THIS: https://git.io/brew-troubleshooting
If reporting this issue please do so at (not Homebrew/homebrew):
  https://github.com/homebrew/homebrew-science/issues

编辑 2: 只是为了好玩,我尝试在没有 --build-from-source 选项的情况下安装 r,并且成功了。请参阅下面的解决方案。 (我认为从源代码构建可能已经解决了 gcc 5 升级的问题,这让事情开始了。我 打算尝试它(事情终于再次发生了.. .why screw with it?), 但我想知道我是否可以删除我在 ~/.R/Makevars 中设置的变量(再次,请参见下面的解决方案)。

从源代码重建 R 为我解决了同样的问题。

brew 重新安装 r --build-from-source

这不是一个完整的修复(它使用较旧的 gcc 版本),但它再次让我 运行:

  1. brew tap homebrew/homebrew-versions
  2. brew install gcc48
  3. brew install r
    • 注意:我 运行 brew install r --build-from-source(重新安装无效),它重建了 something,但不是 r(它失败了)。它可能对这项工作负有部分责任。如果是,请告诉我!如果他的回答是成功的原因,我想赞扬@lmw。
  4. 编辑 ~/.R/Makevars 并添加以下行(根据需要编辑路径):

    CC=/usr/local/Cellar/gcc48/4.8.4/bin/gcc-4.8
    CXX=/usr/local/Cellar/gcc48/4.8.4/bin/g++-4.8
    CFLAGS=-std=c99
    
  5. 运行 r.

  6. (如果您正在尝试安装 bioconductor)

    source("http://bioconductor.org/biocLite.R")
    biocLite()
    

此问题已由 this commit 解决,并为 R 使用了新瓶。确保 brew updatebrew upgrade r