Python clang: error:: errorunsupported option '-fopenmp' on Mac OSX El Capitan building XGBoost

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36211018/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 17:33:38  来源:igfitidea点击:

clang: error: : errorunsupported option '-fopenmp' on Mac OSX El Capitan building XGBoost

pythonmacosgccxgboost

提问by srodriguex

I'm trying to build XGBoostpackage for Python following these instructions:

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

Here is the complete solution to use OpenMP-enabled compilers to install XGBoost. Obtain gcc-5.x.x with openmp support by brew install gcc --without-multilib. (brew is the de facto standard of apt-get on OS X. So installing HPC separately is not recommended, but it should work.):

这是使用支持 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

This error occurss precisely in the make -j4command.

该错误恰好发生在make -j4命令中。

Searching beforenad, I've tried these two solutions (1and 2), to no avail, except for the part to installing another gcc by fear of messing up everything.

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

Below is the makeconfiguration file. It has none suspicious about.

下面是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

回答by

You installed gccwith Homebrew, yet the error is from clang. That should simply mean that your default compiler still points to clanginstead of the newly installed gcc. If you read the comments in the Makefile, you'll see the following lines:

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

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

and in your case, you don't want the system one.
Note: gccfor the system points to clang:

在你的情况下,你不想要系统。
注: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

Instead, point those variables to something in /usr/local/bin, e.g.:

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

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

and similar for the other two variables, CXXand MPICXX, e.g.:

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

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

回答by Sahan Jayasumana

Sir, perhaps you should use

先生,也许你应该使用

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

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

instead of

代替

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

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

as per the "Build On OSX" Section of build document

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

回答by joaofbsm

To solve this issue I did the following: I realized I had gcc6 installed, so I ran:

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

export CC=gcc-6

But it didn't work by itself, so I had to also:

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

export CXX=g++-6

This solved it for me. I'm in a Macbook Pro running macOS Sierra. You can also make those changes directly on XGBoost's Makefile if you want. For more info about this: https://www.ibm.com/developerworks/community/blogs/jfp/entry/Installing_XGBoost_on_Mac_OSX?lang=en

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

回答by Claude COULOMBE

Unable to compile the native libxgboost.dylib library, maybe check this workaround

无法编译本机 libxgboost.dylib 库,请检查此解决方法