r - Conda 构建 R 包在 MacOS Mojave 上的 C 编译器问题上失败

标签 r gcc anaconda conda conda-build

我正在尝试使用 conda 安装一个名为 treatSens 的 R 包,以便在 Jupyter notebook 中使用它。我执行的命令:

conda 安装 conda-build conda 骨架 cran treatSens conda 构建 r-treatsens conda install -c 本地 r-treatsens

我得到了关于 C 编译器的错误

* installing *source* package ‘dbarts’ ...
** package ‘dbarts’ successfully unpacked and MD5 sums checked
checking for gcc... x86_64-apple-darwin13.4.0-clang
checking whether the C compiler works... no
configure: error: in `/Users/myusername/anaconda3/conda-bld/r-dbarts_1543961434509/myenvname':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘dbarts’

我的 clang 版本:

clang version 4.0.1 (tags/RELEASE_401/final)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Users/myusername/anaconda3/envs/myenvname/bin

查看我看到的 config.log 文件

configure:3570: x86_64-apple-darwin13.4.0-clang -V >&5
clang-4.0: error: argument to '-V' is missing (expected 1 value)
clang-4.0: error: no input files
configure:3581: $? = 1
configure:3570: x86_64-apple-darwin13.4.0-clang -qversion >&5
clang-4.0: error: unknown argument: '-qversion'
clang-4.0: error: no input files
configure:3581: $? = 1
configure:3601: checking whether the C compiler works
configure:3623: x86_64-apple-darwin13.4.0-clang -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -I/Users/myusername/anaconda3/envs/work/conda-bld/r-dbarts_1543961045662/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/include -fdebug-prefix-map=/Users/myusername/anaconda3/envs/work/conda-bld/r-dbarts_1543961045662/work=/usr/local/src/conda/r-dbarts-0.9_5 -fdebug-prefix-map=/Users/myusername/anaconda3/envs/work/conda-bld/r-dbarts_1543961045662/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol=/usr/local/src/conda-prefix -D_FORTIFY_SOURCE=2 -mmacosx-version-min=10.9 -I/Users/myusername/anaconda3/envs/work/conda-bld/r-dbarts_1543961045662/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/include -Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,/Users/myusername/anaconda3/envs/work/conda-bld/r-dbarts_1543961045662/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/lib -L/Users/myusername/anaconda3/envs/work/conda-bld/r-dbarts_1543961045662/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/lib conftest.c  >&5
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd, file was built for unsupported file format ( 0x2D 0x2D 0x2D 0x20 0x21 0x74 0x61 0x70 0x69 0x2D 0x74 0x62 0x64 0x2D 0x76 0x33 ) which is not the architecture being linked (x86_64): /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd
ld: dynamic main executables must link with libSystem.dylib for architecture x86_64
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)

这似乎是使用特定版本的 Apple C 编译器构建 Conda 的问题。我的猜测是我需要为 conda build 定制 C 编译器。所以我的问题变成了

  1. 我需要什么正确的 gcc 版本。
  2. 如何为 conda build设置它。

最佳答案

作为一种快速而肮脏的解决方法(来自 comment),我能够在 RStudio 中使用以下代码在 R 中安装包(在 conda env 中打开)

Sys.setenv(CONDA_BUILD_SYSROOT="/")

现在,您可以通过 RStudio 控制台安装任何 R 包,例如

install.packages("tidyverse")

希望这对您有所帮助。

关于r - Conda 构建 R 包在 MacOS Mojave 上的 C 编译器问题上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53637414/

相关文章:

r - 无法在 R 中使用 system.file 或 file.path 加载文件?

css - R Shiny 的表格改变标题和浅暗模式切换

GCC:如何将库编译成一个 C 文件?

R 无法在 centos 6.5 上安装软件包

python - 如何在 anaconda 中安装 PyQt4?

r - 使用频率提取 R 中的变量

r - 如何在 Rcpp 中创建向量列表?

C - 为什么我在尝试读取包含反斜杠的字符时遇到段错误?

python - 使用 Anaconda 安装 MySQLdb

python-3.x - 创建环境Python-3.5错误