clang:error :::在Mac OSX El Capitan构建XGBoost上的错误支持选项'-fopenmp'

sro*_*uex 23 python macos gcc xgboost

我正在尝试按照以下说明为Python 构建XGBoost包:

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

git clone --recursive https://github.com/dmlc/xgboost
cd xgboost; cp make/config.mk ./config.mk; make -j4
Run Code Online (Sandbox Code Playgroud)

此错误恰好在make -j4命令中发生.

在beforenad之前搜索,我尝试了这两个解决方案(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
Run Code Online (Sandbox Code Playgroud)

小智 33

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

# choice of compiler, by default use system preference.
# export CC = gcc
# export CXX = g++
# export MPICXX = mpicxx
Run Code Online (Sandbox Code Playgroud)

在你的情况下,你不希望系统一个.
注意: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
Run Code Online (Sandbox Code Playgroud)

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

$ export CC=/usr/local/bin/gcc
Run Code Online (Sandbox Code Playgroud)

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

$ export CC=/usr/local/bin/gcc;CXX=/usr/local/bin/g++;MPICXX=/usr/local/bin/mpicxx
Run Code Online (Sandbox Code Playgroud)

  • 试试runnng`ls/usr/local/bin/gcc*`,我认为它是`gcc-5`或者其他的.你需要使用上面的`export CC = ...`. (2认同)
  • @srodriguex 注意:*与其他两个变量类似。*。CXX abd MPICXX 也需要定义。 (2认同)

小智 9

先生,也许你应该使用

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

代替

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

根据构建文档的"Build On OSX"部分

  • 做了接受的答案然后这解决了我的问题. (3认同)