Friday, March 25, 2016

Install xgboost on Mac - ld: library not found

Leave a Comment

I am trying to install OpenMP enabled xgboost on my mac. I installed gcc with no problem:

brew install gcc --without-multilib 

then cloned git repository:

git clone --recursive https://github.com/dmlc/xgboost cd xgboost; cp make/config.mk ./config.mk 

but I get an error when I do

make -j4 

Here is the error I get. I'd appreciate if you can help fixing this problem:

c++ -std=c++0x -Wall -O3 -msse2  -Wno-unknown-pragmas -funroll-loops -Iinclude   -Idmlc-core/include -Irabit/include -fPIC -fopenmp -o xgboost  build/cli_main.o build/learner.o build/logging.o build/c_api/c_api.o build/c_api/c_api_error.o build/common/common.o build/data/data.o build/data/simple_csr_source.o build/data/simple_dmatrix.o build/data/sparse_page_dmatrix.o build/data/sparse_page_raw_format.o build/data/sparse_page_source.o build/data/sparse_page_writer.o build/gbm/gblinear.o build/gbm/gbm.o build/gbm/gbtree.o build/metric/elementwise_metric.o build/metric/metric.o build/metric/multiclass_metric.o build/metric/rank_metric.o build/objective/multiclass_obj.o build/objective/objective.o build/objective/rank_obj.o build/objective/regression_obj.o build/tree/tree_model.o build/tree/tree_updater.o build/tree/updater_colmaker.o build/tree/updater_histmaker.o build/tree/updater_prune.o build/tree/updater_refresh.o build/tree/updater_skmaker.o build/tree/updater_sync.o dmlc-core/libdmlc.a rabit/lib/librabit.a  -pthread -lm  -fopenmp  c++ -std=c++0x -Wall -O3 -msse2  -Wno-unknown-pragmas -funroll-loops -Iinclude   -Idmlc-core/include -Irabit/include -fPIC -fopenmp -shared -o lib/libxgboost.so build/learner.o build/logging.o build/c_api/c_api.o build/c_api/c_api_error.o build/common/common.o build/data/data.o build/data/simple_csr_source.o build/data/simple_dmatrix.o build/data/sparse_page_dmatrix.o build/data/sparse_page_raw_format.o build/data/sparse_page_source.o build/data/sparse_page_writer.o build/gbm/gblinear.o build/gbm/gbm.o build/gbm/gbtree.o build/metric/elementwise_metric.o build/metric/metric.o build/metric/multiclass_metric.o build/metric/rank_metric.o build/objective/multiclass_obj.o build/objective/objective.o build/objective/rank_obj.o build/objective/regression_obj.o build/tree/tree_model.o build/tree/tree_updater.o build/tree/updater_colmaker.o build/tree/updater_histmaker.o build/tree/updater_prune.o build/tree/updater_refresh.o build/tree/updater_skmaker.o build/tree/updater_sync.o dmlc-core/libdmlc.a rabit/lib/librabit.a -pthread -lm  -fopenmp  clangclang: : warningwarning: : argument unused during compilation: '-pthread'argument unused during compilation: '-pthread'  ld: library not found for -lgomp ld: library not found for -lgomp clang: error: clanglinker command failed with exit code 1 (use -v to see invocation):  error: linker command failed with exit code 1 (use -v to see invocation) make: *** [lib/libxgboost.so] Error 1 make: *** Waiting for unfinished jobs.... make: *** [xgboost] Error 1 

2 Answers

Answers 1

A new versions of OSX has a Clang as a default c\c++ compiler. Therefore your c++ command refers to clang++.

You should define a CC\CXX environmental variables for your make command like this CC=gcc CXX=g++ make -j

Also you can build an OpenMP for clang OpenMPrt and customise your shell environment (I didn't try this by own)

(I have no mac at this moment to check this solution; just linux)

Answers 2

I have the same issue and solved it by:

brew install clang-omp export CC=clang-omp export CXX=clang-omp++ git clone --recursive https://github.com/dmlc/xgboost cd xgboost; cp make/config.mk ./config.mk; make -j4 cd python-package sudo python setup.py install 

If you used pip to install xgboost before, then delete the previous installed xgboost from your project. Then use

pip install xgboost  

to install it again.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment