24

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

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.):

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 -j4 command.

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

Below is the make configuration file. It has none suspicious about.

#-----------------------------------------------------
#  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
Community
  • 1
  • 1
srodriguex
  • 2,900
  • 3
  • 18
  • 28

4 Answers4

34

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

# 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: gcc for the system points to 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.:

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

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

$ export CC=/usr/local/bin/gcc;CXX=/usr/local/bin/g++;MPICXX=/usr/local/bin/mpicxx
  • In my system, the command `which gcc` gives me this: `/usr/bin/gcc `. I then run the command in terminal: `export CC=/usr/bin/gcc`. The error still goes on. I`m not very expert in `gcc`, `make` and the like. – srodriguex Mar 24 '16 at 22:50
  • 3
    Try runnng `ls /usr/local/bin/gcc*` and I think it'l be `gcc-5` or somesuch. You need to use that with the `export CC=...` above. – Mark Setchell Mar 24 '16 at 22:52
  • 1
    The `ls /usr/local/bin/gcc*` gives me a list of links, one of them ends with `gcc-5`. Then I run the command `export CC=/usr/local/bin/gcc-5`. I also put this command in the make file configuration, to no avail. :( – srodriguex Mar 24 '16 at 23:09
  • 1
    Hei! the command `echo $CC` gives me the original `/usr/bin/gcc`. But the result of command `export` alone gives me a bunch of declares, one of them with the variable `CC` correctly pointing to `/usr/local/bin/gcc-5`. What the hell is goin on? – srodriguex Mar 24 '16 at 23:12
  • 2
    @srodriguex Note: *and similar for the other two variables.*. CXX abd MPICXX also need to be defined. –  Mar 25 '16 at 01:41
  • This saved my life. – Ayan Mitra Feb 21 '19 at 08:31
9

Sir, perhaps you should use

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

instead of

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

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

Sahan Jayasumana
  • 440
  • 6
  • 10
3

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

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

joaofbsm
  • 625
  • 5
  • 13
0

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

Claude COULOMBE
  • 3,434
  • 2
  • 36
  • 39