0

Im trying to set up a custom version of XGBoost from https://github.com/robjhyndman/M4metalearning in R.

When I run devtools::install_github("pmontman/customxgboost") I get this error:

> devtools::install_github("pmontman/customxgboost")
Downloading GitHub repo pmontman/customxgboost@master
✔  checking for file ‘/private/var/folders/5g/1cypnkxn3fs6tbk5ylfp1rqm0000gn/T/RtmpwXcO18/remotes1ff65ae3da8c/pmontman-customxgboost-ac8dacf/DESCRIPTION’ ...
─  preparing ‘xgboost’:
✔  checking DESCRIPTION meta-information ...
─  cleaning src
✔  checking vignette meta-information ...
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  looking to see if a ‘data/datalist’ file should be added
─  building ‘xgboost_666.6.4.1.tar.gz’
   Warning: file 'xgboost/cleanup' did not have execute permissions: corrected

* installing *source* package ‘xgboost’ ...
configure: creating ./config.status
config.status: creating src/Makevars
** libs
/usr/local/bin/gcc-8 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I./include -I./dmlc-core/include -I./rabit/include -I. -DXGBOOST_STRICT_R_MODE=1 -DDMLC_LOG_BEFORE_THROW=0 -DDMLC_ENABLE_STD_THREAD=0 -DDMLC_DISABLE_STDIN=1 -DDMLC_LOG_CUSTOMIZE=1 -DXGBOOST_CUSTOMIZE_LOGGER=1 -DRABIT_CUSTOMIZE_MSG_ -DRABIT_STRICT_CXX98_  -I/usr/local/include  -fopenmp  -fPIC  -Wall -g -O2 -c xgboost_R.cc -o xgboost_R.o
/usr/local/bin/gcc-8 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I./include -I./dmlc-core/include -I./rabit/include -I. -DXGBOOST_STRICT_R_MODE=1 -DDMLC_LOG_BEFORE_THROW=0 -DDMLC_ENABLE_STD_THREAD=0 -DDMLC_DISABLE_STDIN=1 -DDMLC_LOG_CUSTOMIZE=1 -DXGBOOST_CUSTOMIZE_LOGGER=1 -DRABIT_CUSTOMIZE_MSG_ -DRABIT_STRICT_CXX98_  -I/usr/local/include  -fopenmp  -fPIC  -Wall -g -O2 -c xgboost_custom.cc -o xgboost_custom.o
/usr/local/bin/gcc-8 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I./include -I./dmlc-core/include -I./rabit/include -I. -DXGBOOST_STRICT_R_MODE=1 -DDMLC_LOG_BEFORE_THROW=0 -DDMLC_ENABLE_STD_THREAD=0 -DDMLC_DISABLE_STDIN=1 -DDMLC_LOG_CUSTOMIZE=1 -DXGBOOST_CUSTOMIZE_LOGGER=1 -DRABIT_CUSTOMIZE_MSG_ -DRABIT_STRICT_CXX98_  -I/usr/local/include   -fPIC  -Wall -g -O2  -c xgboost_assert.c -o xgboost_assert.o
/usr/local/bin/gcc-8 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I./include -I./dmlc-core/include -I./rabit/include -I. -DXGBOOST_STRICT_R_MODE=1 -DDMLC_LOG_BEFORE_THROW=0 -DDMLC_ENABLE_STD_THREAD=0 -DDMLC_DISABLE_STDIN=1 -DDMLC_LOG_CUSTOMIZE=1 -DXGBOOST_CUSTOMIZE_LOGGER=1 -DRABIT_CUSTOMIZE_MSG_ -DRABIT_STRICT_CXX98_  -I/usr/local/include   -fPIC  -Wall -g -O2  -c init.c -o init.o
/usr/local/bin/gcc-8 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I./include -I./dmlc-core/include -I./rabit/include -I. -DXGBOOST_STRICT_R_MODE=1 -DDMLC_LOG_BEFORE_THROW=0 -DDMLC_ENABLE_STD_THREAD=0 -DDMLC_DISABLE_STDIN=1 -DDMLC_LOG_CUSTOMIZE=1 -DXGBOOST_CUSTOMIZE_LOGGER=1 -DRABIT_CUSTOMIZE_MSG_ -DRABIT_STRICT_CXX98_  -I/usr/local/include  -fopenmp  -fPIC  -Wall -g -O2 -c amalgamation/xgboost-all0.cc -o amalgamation/xgboost-all0.o
/usr/local/bin/gcc-8 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I./include -I./dmlc-core/include -I./rabit/include -I. -DXGBOOST_STRICT_R_MODE=1 -DDMLC_LOG_BEFORE_THROW=0 -DDMLC_ENABLE_STD_THREAD=0 -DDMLC_DISABLE_STDIN=1 -DDMLC_LOG_CUSTOMIZE=1 -DXGBOOST_CUSTOMIZE_LOGGER=1 -DRABIT_CUSTOMIZE_MSG_ -DRABIT_STRICT_CXX98_  -I/usr/local/include  -fopenmp  -fPIC  -Wall -g -O2 -c amalgamation/dmlc-minimum0.cc -o amalgamation/dmlc-minimum0.o
/usr/local/bin/gcc-8 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I./include -I./dmlc-core/include -I./rabit/include -I. -DXGBOOST_STRICT_R_MODE=1 -DDMLC_LOG_BEFORE_THROW=0 -DDMLC_ENABLE_STD_THREAD=0 -DDMLC_DISABLE_STDIN=1 -DDMLC_LOG_CUSTOMIZE=1 -DXGBOOST_CUSTOMIZE_LOGGER=1 -DRABIT_CUSTOMIZE_MSG_ -DRABIT_STRICT_CXX98_  -I/usr/local/include  -fopenmp  -fPIC  -Wall -g -O2 -c rabit/src/engine_empty.cc -o rabit/src/engine_empty.o
/usr/local/bin/gcc-8 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I./include -I./dmlc-core/include -I./rabit/include -I. -DXGBOOST_STRICT_R_MODE=1 -DDMLC_LOG_BEFORE_THROW=0 -DDMLC_ENABLE_STD_THREAD=0 -DDMLC_DISABLE_STDIN=1 -DDMLC_LOG_CUSTOMIZE=1 -DXGBOOST_CUSTOMIZE_LOGGER=1 -DRABIT_CUSTOMIZE_MSG_ -DRABIT_STRICT_CXX98_  -I/usr/local/include  -fopenmp  -fPIC  -Wall -g -O2 -c rabit/src/c_api.cc -o rabit/src/c_api.o
/usr/local/bin/gcc-8 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o xgboost.so ./xgboost_R.o ./xgboost_custom.o ./xgboost_assert.o ./init.o ./amalgamation/xgboost-all0.o ./amalgamation/dmlc-minimum0.o ./rabit/src/engine_empty.o ./rabit/src/c_api.o -fopenmp -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/3.5/Resources/library/xgboost/libs
** R
** data
** demo
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error: package or namespace load failed for ‘xgboost’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/xgboost/libs/xgboost.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/xgboost/libs/xgboost.so, 6): Symbol not found: __ZNSt11regex_errorD1Ev
  Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/xgboost/libs/xgboost.so
  Expected in: flat namespace
 in /Library/Frameworks/R.framework/Versions/3.5/Resources/library/xgboost/libs/xgboost.so
Error: loading failed
Ejecución interrumpida
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/xgboost’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/xgboost’
Error in i.p(...) : 
  (convertido del aviso) installation of package ‘/var/folders/5g/1cypnkxn3fs6tbk5ylfp1rqm0000gn/T//RtmpwXcO18/file1ff67e4c38d5/xgboost_666.6.4.1.tar.gz’ had non-zero exit status

Im using

My ~/.R/Makevars file is as follow:

CC=/usr/local/bin/gcc-8
CXX=/usr/local/bin/g++-8
CXX11=/usr/local/bin/gcc-8

I also tried install the original XGBoost following this guide : https://xgboost.readthedocs.io/en/latest/build.html

and everything gone well. So the problem is exclusively of R, im a little stuck. Any suggerences?

VYago
  • 325
  • 2
  • 9

1 Answers1

2

Finally I fix the problem, im going to describe the entire process.

In essence you have to follow this steps:

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

Specifically this is important: brew install gcc@8

This command download the version of gcc that supports openMP an important library to XGBoost due to the nature of some parallel characteristics.

Maybe the shared library xgboost.so fails due to a "symbol not found error". This occurs when your are trying to link objects compiled from different gcc versions.

More info here: What does "Symbol not found / Expected in: flat namespace" actually mean?

To fix this I changed the contents of ~/.R/Makevars file to :

CC=/usr/local/bin/gcc-8 CXX=/usr/local/bin/g++-8 CXX11=/usr/local/bin/g++-8

Note CX11 is different from original question version.

This solved my problem.

More info about Makevars file here : Understanding the contents of the Makevars file in R (macros, variables, ~/.R/Makevars and pkg/src/Makevars)

If the above fails it is recommended to delete the R libraries and reinstall it, there may be a problem with a symbolic link or similar.

R libraries (Mac Os High Sierra) are stored here:

/Library/Frameworks/R.framework/Versions/3.5/Resources/library/

VYago
  • 325
  • 2
  • 9