[当我想在cenos7(是wsl2)中从cran安装xgboost时,出现此错误,并且我无法通过Google找到任何线索:
In file included from amalgamation/xgboost-all0.cc:68:0:
amalgamation/../src/learner.cc: In member function ‘virtual void xgboost::LearnerImpl::SaveModel(xgboost::Json*) const ’:
amalgamation/../src/learner.cc:378:24: error: invalid initialization of non-const reference of type ‘xgboost::Json&’ from an rvalue of type ‘<brace-enclosed initializer list>’
Json& out { *p_out };
^
amalgamation/../src/learner.cc: In member function ‘virtual void xgboost::LearnerImpl::SaveConfig(xgboost::Json*) cons
’:
amalgamation/../src/learner.cc:441:24: error: invalid initialization of non-const reference of type ‘xgboost::Json&’ from an rvalue of type ‘<brace-enclosed initializer list>’
Json& out { *p_out };
^
make: *** [amalgamation/xgboost-all0.o] Error 1
ERROR: compilation failed for package ‘xgboost’
* removing ‘/usr/lib64/R/library/xgboost’
环境是:
> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)
Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.6.0 tools_3.6.0
默认gcc版本是4.8.5,为了编译'rstan',我写了
CXX14 = g++ -std=c++1y
CXX14FLAGS += -fPIC
进入文件〜/ .R / Makevars
我如何成功安装xgboost?
尝试从github(https://xgboost.readthedocs.io/en/latest/build.html#installing-the-development-version)获得开发包:
git clone --recursive https://github.com/dmlc/xgboost
cd xgboost
git submodule init
git submodule update
mkdir build
cd build
cmake .. -DR_LIB=ON
make -j$(nproc)
make install
使用默认目标时,将在构建区域中构建R软件包共享库。此外,安装目标使用此共享库在build / R-package下组装软件包文件,并运行R CMD INSTALL。