Conda build R软件包在MacOS Mojave上的C编译器问题上失败

时间:2018-12-05 17:09:31

标签: r gcc anaconda conda conda-build

我正在尝试使用conda安装一个名为TreatSens的R软件包,以在Jupyter笔记本中使用它。我执行的命令:

conda install conda-build conda skeleton cran treatSens conda build r-treatsens conda install -c local 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构建自定义C编译器。所以我的问题变成了

  1. 我需要什么正确的gcc版本。
  2. 如何将其设置为conda构建。

2 个答案:

答案 0 :(得分:1)

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

Sys.setenv(CONDA_BUILD_SYSROOT="/")

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

install.packages("tidyverse")

希望这会有所帮助。

答案 1 :(得分:0)

要使MacOS Mojave正常构建,必须执行几项操作。由于对我来说很神秘的原因,Anaconda的人们not keen使之顺畅,这对于使用深奥R包的我们这些人来说尤其令人发疯。我将写出截至2019-04-20的最新信息:

1。安装Xcode(v10.2.1)

2。在开放源代码的地方安装标题通常会期望找到它们。在命令行中:

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

3。安装命令行工具

  • 作为安全带方法,我从https://developer.apple.com/download/more/下载并安装了DMG Command_Line_Tools_macOS_10.14_for_Xcode_10.2.1
  • 我相信xcode-select --install也会这样做。如果运行该命令,您应该会看到消息
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

4。下载旧版MacOS SDK文件的副本。例如,来自here

5。创建目录/opt

sudo mkdir /opt

6。将SDK文件复制到此处

sudo cp -r ~/Downloads/MacOSX10.9.sdk /opt/

sudo chmod -R a+rX /opt

7。创建一个conda_build_config.yaml文件,Conda-build和相关软件将引用该文件。它应包含以下内容

macos_min_version:
  - 10.9
macos_machine:
  - x86_64-apple-darwin13.4.0
MACOSX_DEPLOYMENT_TARGET:
  - 10.9
CONDA_BUILD_SYSROOT:            # [osx]
  - /opt/MacOSX10.9.sdk          # [osx]

在终端中,您可以执行以下操作:

mkdir ~/.conda || echo 'Dir already present'
cat "macos_min_version:" >> ~/.conda/conda_build_config.yaml
cat "  - 10.9" >> ~/.conda/conda_build_config.yaml
cat "macos_machine:" >> ~/.conda/conda_build_config.yaml
cat "  - x86_64-apple-darwin13.4.0" >> ~/.conda/conda_build_config.yaml
cat "MACOSX_DEPLOYMENT_TARGET:" >> ~/.conda/conda_build_config.yaml
cat "  - 10.9" >> ~/.conda/conda_build_config.yaml
cat "CONDA_BUILD_SYSROOT:" >> ~/.conda/conda_build_config.yaml
cat "  - /opt/MacOSX10.9.sdk" >> ~/.conda/conda_build_config.yaml

8。通过您的.condarc告诉Conda您的YAML文件。它应该包含以下行:

conda_build:   
  config_file: ~/.conda/conda_build_config.yaml

可以使用

完成
cat "conda_build:" >> ~/.condarc
cat "  config_file: ~/.conda/conda_build_config.yaml" >> ~/.condarc