Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ld: library not found for -lgomp & clang: error: linker command failed with exit code 1 #2150

Closed
KrisWu618 opened this issue Mar 26, 2017 · 1 comment

Comments

@KrisWu618
Copy link

Environment info

Operating System:
mac OS X Yosemite 10.10.5

Package used (python/R/jvm/C++):
python 3.5

$brew tap homebrew/boneyard
$brew install clang-omp
$brew reinstall gcc --without-multilib

$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.5.0
Thread model: posix

$ clang -v
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.5.0
Thread model: posix

Below please find the steps and errors when I install xgboost.

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

c++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -O3 -funroll-loops -msse2 -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/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
c++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/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
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
ld: library not found for -lgomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [lib/libxgboost.so] Error 1
make: *** Waiting for unfinished jobs....

ld: library not found for -lgomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [xgboost] Error 1

I have saw a couple of people having the same issues. But I am not clear about how to solve it.

#3
Here the solution mentioned I need to install OpenMP, which I already did. And it says I need to remove -fopenmp in Makefile, but I didn't find it in Makefile.

#29
Here the solution mentioned "See the build guide, in README.md you need to remove -fopenmp flag". But I didn't see -fopenmp in the README.md.

I have no idea about "ld: library not found for -lgomp; clang: error: linker command failed with exit code 1 (use -v to see invocation)". Can anybody help me?

Thank you very much.

@KrisWu618
Copy link
Author

KrisWu618 commented Mar 28, 2017

Problem solved! My case was a little complicated. I have tried installing xgboost last year but it did not work out. I gave up. Recently I wanted to reinstall it so that I can play with Kaggle. It took me three days to figure out all the issues. There were a couple of steps how I reinstall it.

First, I need to reinstall brew and install clang-omp. If you have compile issue, you may need to do it as well.

$brew tap homebrew/boneyard
$brew install clang-omp
$brew reinstall gcc --without-multilib

Second, I removed xgboost file I downloaded last year.

$cd
$ls 
$rm -rf xgboost

Then, I tried to reinstall xgboost.
$git clone --recursive https://github.com/dmlc/xgboost

Go to Makefile and make/config.mk. Replace the following code:
export CC = gcc
export CXX = g++

export CC = gcc-6
export CXX = g++-6

I still have issue with -fopenmp and -lgomp. I found the solution here #1839

The above issue was solved by the code:

cd xgboost; 
cp make/config.mk ./config.mk; 
make clean_all && make -j4

It worked out. I have tried install xgboost in python.
cd python-package; sudo python setup.py install
But it shows error that 'no such file'. I looked into the file and noticed my python-package was under xgboost file. So I change the path:
cd xgboost/python-package; sudo python setup.py install

Finally I can use xgboost!! Yay!

Reference:

  1. https://xgboost.readthedocs.io/en/latest/build.html
  2. https://www.ibm.com/developerworks/community/blogs/jfp/entry/Installing_XGBoost_on_Mac_OSX?lang=en
  3. [mac] ld: symbol(s) not found for architecture x86_64 #1839

@tqchen tqchen closed this as completed Jul 4, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Oct 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants