【问题标题】:clang: error: : errorunsupported option '-fopenmp' on Mac OSX El Capitan building XGBoost铿锵声:错误::Mac OSX El Capitan 构建 XGBoost 上的错误不支持选项“-fopenmp”
【发布时间】:2016-07-12 16:23:20
【问题描述】:

我正在尝试在these instructions 之后为 Python 构建 XGBoost 包:

这是使用支持 OpenMP 的编译器安装 XGBoost 的完整解决方案。通过brew install gcc --without-multilib 获取支持openmp 的gcc-5.x.x。 (brew 是 OS X 上 apt-get 的事实标准。因此不建议单独安装 HPC,但应该可以。):

git clone --recursive https://github.com/dmlc/xgboost
cd xgboost; cp make/config.mk ./config.mk; make -j4

这个错误恰好出现在make -j4 命令中。

在搜索之前,我已经尝试了这两种解决方案(12),但无济于事,除了安装另一个 gcc 的部分,因为害怕搞砸一切。

下面是make 配置文件。它没有任何可疑之处。

#-----------------------------------------------------
#  xgboost: the configuration compile script
#
#  If you want to change the configuration, please use the following
#  steps. Assume you are on the root directory of xgboost.
#  First copy the this file so that any local changes will be ignored by git
#
#  $ cp make/config.mk .
#
#  Next modify the according entries, and then compile by
#
#  $ make
#
#  or build in parallel with 8 threads
#
#  $ make -j8
#----------------------------------------------------

# choice of compiler, by default use system preference.
# export CC = gcc
# export CXX = g++
# export MPICXX = mpicxx

# the additional link flags you want to add
ADD_LDFLAGS =

# the additional compile flags you want to add
ADD_CFLAGS =

# Whether enable openmp support, needed for multi-threading.
USE_OPENMP = 1

# whether use HDFS support during compile
USE_HDFS = 0

# whether use AWS S3 support during compile
USE_S3 = 0

# whether use Azure blob support during compile
USE_AZURE = 0

# Rabit library version,
# - librabit.a Normal distributed version.
# - librabit_empty.a Non distributed mock version,
LIB_RABIT = librabit.a

# path to libjvm.so
LIBJVM=$(JAVA_HOME)/jre/lib/amd64/server

# List of additional plugins, checkout plugin folder.
# uncomment the following lines to include these plugins
# you can also add your own plugin like this
#
# XGB_PLUGINS += plugin/example/plugin.mk

【问题讨论】:

  • 仔细阅读Makefile中的cmets。

标签: python macos gcc xgboost


【解决方案1】:

您使用 Homebrew 安装了 gcc,但错误来自 clang。这应该只是意味着您的默认编译器仍然指向clang,而不是新安装的gcc。如果您阅读 Makefile 中的 cmets,您将看到以下几行:

# choice of compiler, by default use system preference.
# export CC = gcc
# export CXX = g++
# export MPICXX = mpicxx

在你的情况下,你不想要系统。
注意:gcc为系统指向clang

$ which gcc
/usr/bin/gcc
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.29)
Target: x86_64-apple-darwin15.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

相反,将这些变量指向/usr/local/bin 中的某个内容,例如:

$ export CC=/usr/local/bin/gcc

其他两个变量类似,CXXMPICXX,例如:

$ export CC=/usr/local/bin/gcc;CXX=/usr/local/bin/g++;MPICXX=/usr/local/bin/mpicxx

【讨论】:

  • 在我的系统中,which gcc 命令给了我这个:/usr/bin/gcc 。然后我在终端中运行命令:export CC=/usr/bin/gcc。错误仍在继续。我m not very expert in gcc, make`之类的。
  • 尝试运行ls /usr/local/bin/gcc*,我想它会是gcc-5 或类似的。您需要将其与上面的 export CC=... 一起使用。
  • ls /usr/local/bin/gcc* 给了我一个链接列表,其中一个以gcc-5 结尾。然后我运行命令export CC=/usr/local/bin/gcc-5。我也将此命令放在make文件配置中,但无济于事。 :(
  • 嘿!命令echo $CC 给了我原来的/usr/bin/gcc。但是仅命令export 的结果就给了我一堆声明,其中一个变量CC 正确指向/usr/local/bin/gcc-5。到底是怎么回事?
  • @srodriguex 注意:与其他两个变量类似。。 CXX abd MPICXX 也需要定义。
【解决方案2】:

先生,也许您应该使用

cd xgboost; cp make/minimum.mk ./config.mk;制作-j4

而不是

cd xgboost; cp make/config.mk ./config.mk;制作-j4

根据build document 的“在 OSX 上构建”部分

【讨论】:

  • 做接受的答案然后这已经解决了我的问题。
  • 这对我也有用,但是在执行了上面写的第一步之后,谢谢
  • 是的,您必须先更改导出,我想知道这是一个错误还是与其他问题有关。
【解决方案3】:

为了解决这个问题,我做了以下事情:我意识到我已经安装了gcc 6,所以我运行了:

export CC=gcc-6

但它本身不起作用,所以我也必须:

export CXX=g++-6

这为我解决了这个问题。我在运行 macOS Sierra 的 Macbook Pro 中。如果需要,您也可以直接在 XGBoost 的 Makefile 上进行这些更改。欲了解更多信息:https://www.ibm.com/developerworks/community/blogs/jfp/entry/Installing_XGBoost_on_Mac_OSX?lang=en

【讨论】:

    【解决方案4】:

    无法编译原生的 libxgboost.dylib 库,可以查看workaround

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-09
      • 1970-01-01
      • 2012-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多