From 117f26f865e359830ffa6ef306ff7446b299e458 Mon Sep 17 00:00:00 2001 From: Dat Le Date: Wed, 4 Nov 2015 13:54:56 +0800 Subject: [PATCH 1/2] Updated build.md for OS X Ref: https://github.com/dmlc/xgboost/issues/596 --- doc/build.md | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/doc/build.md b/doc/build.md index b97237bcb..7e762455a 100644 --- a/doc/build.md +++ b/doc/build.md @@ -17,7 +17,9 @@ Here is the complete solution to use OpenMp-enabled compilers to install XGBoost 1. 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](http://hpc.sourceforge.net/) separately is not recommended, but it should work.) -2. **if you are planing to use clang-omp** - in step 3 and/or 4, change line 9 in `xgboost/src/utils/omp.h` to +2. **if you are planing to use clang-omp**: + + 2.1 Change line 9 in `xgboost/src/utils/omp.h` to ```C++ #include /* instead of #include */` @@ -27,27 +29,16 @@ Here is the complete solution to use OpenMp-enabled compilers to install XGBoost `src/tree/../utils/omp.h:9:10: error: 'omp.h' file not found...` - - -3. Set the `Makefile` correctly for compiling cpp version xgboost then python version xgboost. - - ```Makefile - export CC = gcc-4.9 - export CXX = g++-4.9 - ``` - - Or + 2.2 Set the `Makefile` correctly for compiling cpp version xgboost then python version xgboost. ```Makefile 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 `python-package` sub-folder to install python version with `python setup.py install`. - Then `cd xgboost` then `bash build.sh` to compile XGBoost. And go to `wrapper` sub-folder to install python version. - -4. Set the `Makevars` file in highest piority for R. +3. Set the `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!). From bf50d25ea12f24b416bba5b2d849012b5c021e6d Mon Sep 17 00:00:00 2001 From: Dat Le Date: Mon, 16 Nov 2015 10:28:12 +0800 Subject: [PATCH 2/2] Updated build.md for OS X OS X EI Capitan does not seem to stably support the clang build version anymore. --- doc/build.md | 50 +++++--------------------------------------------- 1 file changed, 5 insertions(+), 45 deletions(-) diff --git a/doc/build.md b/doc/build.md index 7e762455a..7eae0bbd0 100644 --- a/doc/build.md +++ b/doc/build.md @@ -15,57 +15,17 @@ Build XGBoost in OS X with OpenMP --------------------------------- Here is the complete solution to use OpenMp-enabled compilers to install XGBoost. -1. 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](http://hpc.sourceforge.net/) separately is not recommended, but it should work.) +1. 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](http://hpc.sourceforge.net/) separately is not recommended, but it should work.) -2. **if you are planing to use clang-omp**: +2. `cd xgboost` then `bash build.sh` to compile XGBoost. - 2.1 Change line 9 in `xgboost/src/utils/omp.h` to +3. Install xgboost package for Python and R - ```C++ - #include /* instead of #include */` - ``` - - to make it work, otherwise you might get this error - - `src/tree/../utils/omp.h:9:10: error: 'omp.h' file not found...` - - 2.2 Set the `Makefile` correctly for compiling cpp version xgboost then python version xgboost. - - ```Makefile - export CC = clang-omp - export CXX = clang-omp++ - ``` - - Then `cd xgboost` then `bash build.sh` to compile XGBoost. And go to `python-package` sub-folder to install python version with `python setup.py install`. - -3. Set the `Makevars` file in highest piority for R. +- For Python: go to `python-package` sub-folder to install python version with `python setup.py install` (or `sudo python setup.py install`). +- For R: Set the `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: - - ```Makefile - 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 - - ```Makefile - 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 ```R