Showing posts with label make. Show all posts
Showing posts with label make. Show all posts

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.

Read More

Saturday, March 12, 2016

Setting PATH/LD_LIBRARY_PATH for 'make check' with QMake

Leave a Comment

I have a project setup with a couple of Apps with a shared library, this is all built nicely using a SUBDIRS project, where the apps depend on the shared library.

TEMPLATE = subdirs SUBDIRS = app1 app2 sharedLib app1.depends = sharedLib app2.depends = sharedLib 

Each app also contains a number of tests, with CONFIG += testcase set.

This creates a check target so we can run all unit test from the top level .pro using make check.

The problem is that some of the app tests require the presence of the code within the sharedLib, therefore it needs to be discoverable according to each platforms library lookup rules.

On Windows one option is to have the sharedLib location on the PATH, on linux we can add the sharedLib location to LD_LIBRARY_PATH, on mac DYLD_LIBRARY_PATH.

One solution is to just set the location of the built shared lib before running make check:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:build/sharedDll/ make check 

and this works, but it seems a little redundant as it is the build scripts themselves that are building the shared library so they know the path to the sharedLib binary location, which can be referenced from within .pro/pri files at:

$$TOP_BUILDDIR/sharedLib/release 

So, is there anyway to set the PATH/LD_LIBRARY_PATH/DYLD_LIBRARY_PATH from within the project files for the purposes of the make check command?

1 Answers

Answers 1

If you are using gcc, you can use rpath parameter of gcc.

-rpath=dir
      Add a directory to the runtime library search path. This is used
      when linking an ELF executable with shared objects. All -rpath
      arguments are concatenated and passed to the runtime linker, which
      uses them to locate shared objects at runtime.

QMAKE_CXXFLAGS += -rpath=/the/absolute/path

If you use that technique, it will not be necessary to edit LD_LIBRARY_PATH

Read More