简体   繁体   English

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

[英]Conda build R package fails at C compiler issue on MacOS Mojave

I'm trying to install an R package called treatSens with conda to use it in Jupyter notebook.我正在尝试使用 conda 安装一个名为treatSens 的 R 包,以便在 Jupyter 笔记本中使用它。 The commands I executed:我执行的命令:

conda install conda-build conda skeleton cran treatSens conda build r-treatsens conda install -c local r-treatsens

And I got the error about C compiler我得到了关于 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’

My clang version:我的叮当版本:

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

Looking into the config.log file I see查看我看到的 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)

It seems it's a problem about Conda build using the certain version of Apple C compiler.使用特定版本的 Apple C 编译器构建 Conda 似乎存在问题。 My guess is that I need to customize the C compiler for conda build.我的猜测是我需要为 conda 构建自定义 C 编译器。 So my question becomes所以我的问题变成

  1. What correct gcc version do I need.我需要什么正确的 gcc 版本。
  2. How to set it for conda build.如何为 conda 构建设置它。

As a quick and dirty workaround (from this comment ), I was able to install packages in R using below code in RStudio (opened in conda env)作为一种快速而肮脏的解决方法(来自此评论),我能够在 RStudio 中使用以下代码在 R 中安装软件包(在 conda env 中打开)

Sys.setenv(CONDA_BUILD_SYSROOT="/")

Now, you can install any R package via RStudio Console eg现在,您可以通过 RStudio 控制台安装任何 R 包,例如

install.packages("tidyverse")

Hope this helps.希望这可以帮助。

There are several things you must do to get things building properly in MacOS Mojave.要在 MacOS Mojave 中正确构建东西,您必须做几件事。 For reasons mysterious to me, the Anaconda folks are not keen to make this smooth, which is especially maddening for those of us who use esoteric R packages.出于对我来说神秘的原因,Anaconda 的人并不热衷于使这一切顺利,这对于我们这些使用深奥的 R 包的人来说尤其令人抓狂。 I will write what seems current as of 2019-04-20:我将写下截至 2019 年 4 月 20 日的最新情况:

1. Install Xcode (v10.2.1) 1. 安装 Xcode (v10.2.1)

2. Install headers in the place open source tends to expect finding them. 2.在开源倾向于找到它们的地方安装头文件 From the command line:从命令行:

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

3. Install the command-line tools 3. 安装命令行工具

  • As a belt-and braces approach, I downloaded and installed the DMG Command_Line_Tools_macOS_10.14_for_Xcode_10.2.1 from https://developer.apple.com/download/more/作为腰带和大括号的方法,我从https://developer.apple.com/download/more/下载并安装了 DMG Command_Line_Tools_macOS_10.14_for_Xcode_10.2.1
  • I believe this is also what is done by xcode-select --install .我相信这也是xcode-select --install所做的。 If you run that command (once the tools are installed), you should see the message如果您运行该命令(安装工具后),您应该看到消息
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

4. Download a copy of older MacOS SDK files . 4. 下载旧版 MacOS SDK 文件的副本 For example, from here例如,从这里

5. Create a directory /opt 5.创建目录/opt

sudo mkdir /opt

6. Copy the SDK files there 6. 将 SDK 文件复制到那里

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

sudo chmod -R a+rX /opt

7. Create a conda_build_config.yaml file that will be referenced by Conda-build and related software. 7. 创建conda_build_config.yaml文件,Conda-build 和相关软件将引用该文件 It should contain the following它应该包含以下内容

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]

In a terminal you can do that with:在终端中,您可以这样做:

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

8. Tell Conda about your YAML file via your .condarc . 8.通过您的.condarc将您的 YAML 文件告诉 Conda It should contain the lines:它应该包含以下几行:

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

which can be accomplished using可以使用

echo "conda_build:" >> ~/.condarc
echo "  config_file: ~/.conda/conda_build_config.yaml" >> ~/.condarc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM