【问题标题】:Conda build R package fails at C compiler issue on MacOS MojaveConda 构建 R 包在 MacOS Mojave 上的 C 编译器问题上失败
【发布时间】:2019-05-07 07:46:59
【问题描述】:

我正在尝试使用 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 build 定制 C 编译器。所以我的问题变成了

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

【问题讨论】:

  • 我没有安装 Mojave,所以我不能尝试这个,但过去我在更新 macOS 后遇到过类似的问题,我不得不打开 Xcode 并单击一些“确认”和“同意”按钮在我可以让一切恢复正常之前。可能值得一试
  • 您的 clang 似乎不在一个典型的位置。 yopu 是否查看过 Macos R 的开发者页面?你有没有回顾过这个类似问题的答案。 stackoverflow.com/questions/52509602/…
  • @42- 以上是在我的 conda 环境中。我尝试安装 xcode cmd line tools 9.3 并删除了最新版本,但我不知道如何使它成为 conda install 的编译器。
  • 为了进一步澄清,我可以毫无问题地在 RStudio 中安装这个包。我的问题是 conda。
  • 我怀疑 conda 使用与 Rstudio 相同的环境变量。当 Rstudio 新用户无法弄清楚为什么事情在终端启动的 R 中运行但在 Rstudio 中运行时,这是一个常见的困惑来源。

标签: r gcc anaconda conda conda-build


【解决方案1】:

您必须做几件事才能在 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'
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.通过您的.condarc 告诉 Conda 您的 YAML 文件。它应该包含以下行:

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

可以使用

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

【讨论】:

    【解决方案2】:

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

    Sys.setenv(CONDA_BUILD_SYSROOT="/")
    

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

    install.packages("tidyverse")
    

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-07
      • 2021-09-22
      • 1970-01-01
      • 1970-01-01
      • 2015-08-09
      相关资源
      最近更新 更多