Ld: library not found for -lomp

On macOS Sierra, an installation for xgboost with openmp enabled always fails.

From https://xgboost.readthedocs.io/en/latest/build.html ,

I 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++ 

Crash

 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 supports openmp, but with an error ld: library not found for -lomp

related question Install xgboost on Mac - ld: library not found

But clang-omp switches to boneyard and stops supporting llvm OpenMP.

I turned up to (with the -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 
+3
source share
2 answers

solvable

 cd /usr/local/lib ln -s /usr/local/Cellar/llvm/4.0.0_1/lib/libomp.dylib libomp.dylib 

llvm do not miss your symlink.

+10
source

In my case, I decided to add the following linker flag in addition to -lomp:

-Lpath_to_libomp.dylib_folder

or something like:

-Llib /

0
source

Source: https://habr.com/ru/post/1269747/


All Articles