src/external/xgboost/doc/build.md
bash build.sh (you can also type make)make cxx11=1
make no_omp=1, this will get you single thread xgboostHere is the complete solution to use OpenMp-enabled compilers to install XGBoost.
Obtain gcc with openmp support by brew install gcc --without-multilib or clang with openmp by brew install clang-omp. The clang one is recommended because the first method requires us compiling gcc inside the machine (more than an hour in mine)! (BTW, brew is the de facto standard of apt-get on OS X. So installing HPC separately is not recommended, but it should work.)
if you are planing to use clang-omp - in step 3 and/or 4, change line 9 in xgboost/src/utils/omp.h to
#include <libiomp/omp.h> /* instead of #include <omp.h> */`
to make it work, otherwise you might get this error
src/tree/../utils/omp.h:9:10: error: 'omp.h' file not found...
Makefile correctly for compiling cpp version xgboost then python version xgboost.export CC = gcc-4.9
export CXX = g++-4.9
Or
export CC = clang-omp
export CXX = clang-omp++
Remember to change header (mentioned in step 2) if using clang-omp.
Then cd xgboost then bash build.sh to compile XGBoost. And go to wrapper sub-folder to install python version.
Makevars file in highest piority for R.The point is, there are three Makevars : ~/.R/Makevars, xgboost/R-package/src/Makevars, and /usr/local/Cellar/r/3.2.0/R.framework/Resources/etc/Makeconf (the last one obtained by running file.path(R.home("etc"), "Makeconf") in R), and SHLIB_OPENMP_CXXFLAGS is not set by default!! After trying, it seems that the first one has highest piority (surprise!).
So, add or change ~/.R/Makevars to the following lines:
CC=gcc-4.9
CXX=g++-4.9
SHLIB_OPENMP_CFLAGS = -fopenmp
SHLIB_OPENMP_CXXFLAGS = -fopenmp
SHLIB_OPENMP_FCFLAGS = -fopenmp
SHLIB_OPENMP_FFLAGS = -fopenmp
Or
CC=clang-omp
CXX=clang-omp++
SHLIB_OPENMP_CFLAGS = -fopenmp
SHLIB_OPENMP_CXXFLAGS = -fopenmp
SHLIB_OPENMP_FCFLAGS = -fopenmp
SHLIB_OPENMP_FFLAGS = -fopenmp
Again, remember to change header if using clang-omp.
Then inside R, run
install.packages('xgboost/R-package/', repos=NULL, type='source')
Or
devtools::install_local('xgboost/', subdir = 'R-package') # you may use devtools
git clone https://github.com/dmlc/dmlc-coremake dmlc=dmlc-core