In macOS Sierra, installation for xgboost with openmp enabled always fails.
From https://xgboost.readthedocs.io/en/latest/build.html
,
I've tried:
cp make/config.mk ./config.mk; make -j4
With,
export CC=/usr/local/Cellar/llvm/4.0.0_1/bin/clang
export CXX=/usr/local/Cellar/llvm/4.0.0_1/bin/clang++
export CXX1X=/usr/local/Cellar/llvm/4.0.0_1/bin/clang++
It fails with,
clang-4.0clang-4.0: : warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]warning:
argument unused during compilation: '-pthread' [-Wunused-command-line-argument]
ld: library not found for -lomp
ld: library not found for -lomp
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
llvm support openmp, but it fails with ld: library not found for -lomp
related question Install xgboost on Mac - ld: library not found
But, clang-omp goes to boneyard, and discontinue with llvm's OpenMP support.
I've drilled down to, (with -v
option)
/usr/local/Cellar/llvm/4.0.0_1/bin/clang++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -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/common/hist_util.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_fast_hist.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
SOLVED
cd /usr/local/lib
ln -s /usr/local/Cellar/llvm/4.0.0_1/lib/libomp.dylib libomp.dylib
llvm installation miss its symbolic link.
In my case I solved adding the following linker flag in addition to -lomp:
-Lpath_to_libomp.dylib_folder
or something like:
-Llib/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With