在linux中为R安装xgboost时出错

时间:2018-02-23 19:25:11

标签: r linux gcc xgboost

我尝试使用以下方法在我的Linux服务器上安装xgboost R软件包:

install.packages("xgboost", lib = "/usr/lib64/R/library")

它给了我一个错误:

trying URL 'https://cran.rstudio.com/src/contrib/xgboost_0.6.4.1.tar.gz'
Content type 'application/x-gzip' length 596978 bytes (582 KB)
==================================================
downloaded 582 KB

* installing *source* package ‘xgboost’ ...
** package ‘xgboost’ successfully unpacked and MD5 sums checked
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -m64 -std=gnu++0x -I/usr/include/R -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  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c xgboost_R.cc -o xgboost_R.o
In file included from ./dmlc-core/include/dmlc/logging.h:15,
                 from xgboost_R.cc:2:
./dmlc-core/include/dmlc/./base.h:71: note: #pragma message: Will need g++-4.6 or higher to compile allthe features in dmlc-core, compile without c++0x, some features may be disabled
xgboost_R.cc: In function ‘SEXPREC* XGBoosterSetAttr_R(SEXPREC*, SEXPREC*, SEXPREC*)’:
xgboost_R.cc:412: error: ‘nullptr’ was not declared in this scope
make: *** [xgboost_R.o] Error 1
ERROR: compilation failed for package ‘xgboost’
* removing ‘/usr/lib64/R/library/xgboost’
Warning in install.packages :
  installation of package ‘xgboost’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpFDEVT8/downloaded_packages’
Updating HTML index of packages in '.Library'
Warning in install.packages :
  cannot create file '/usr/share/doc/R-3.4.2/html/packages.html', reason 'Permission denied'
Warning in install.packages :
  cannot update HTML package index

它表示需要g ++ - 4.6或更高版本。

我将服务器上的gcc从4.4.7更新为4.9.2。但是,它仍然给我同样的错误。

有没有人对这个问题有所了解。怎么解决这个问题?

2 个答案:

答案 0 :(得分:1)

为R准备好较新版本gccg++的一种方法是强制它在系统$PATH的早期出现。除了更改$PATH之外,还可以使用/usr/local/bin/通常在/usr/bin之前发布的事实,以便首选新版本。

因此,我们在gcc我们可以做的

中安装了新的/opt/gcc/gcc-4.9.2/
cd /usr/local/bin
sudo ln -s /opt/gcc/gcc-4.9.3/bin/gcc .
sudo ln -s /opt/gcc/gcc-4.9.3/bin/g++ .

这可能就足够了。可以添加ldasar,...,但并非总是需要。根据需要调整路径,并确保将实际可执行文件(即gcc)链接到/usr/local/bin

选中gcc --version

答案 1 :(得分:0)

我有xgboost安装问题。但是,可以安装较旧的存档版本('0.90.0.2'),并且可以运行!

packageurl <- "http://cran.r- 
project.org/src/contrib/Archive/xgboost/xgboost_0.90.0.2.tar.gz"

install.packages(packageurl, repos=NULL, type="source")