install.packages("RcppArmadillo")
CentOS 7
R version 3.6.0 (2019-04-26) -- "Planting of a Tree"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)
试开URL’https://mirrors.sjtug.sjtu.edu.cn/cran/src/contrib/RcppArmadillo_0.10.1.0.0.tar.gz'
RcppArmadillo.cpp:26:40: 错误:对‘arma::arma_version::major’的重声明在‘constexp’方面
const unsigned int arma::arma_version::major;
^
In file included from ../inst/include/armadillo:91:0,
from ../inst/include/RcppArmadilloForward.h:49,
from ../inst/include/RcppArmadillo.h:31,
from RcppArmadillo.cpp:22:
../inst/include/armadillo_bits/arma_version.hpp:31:33: 错误:与先前的声明‘arma::arma_version::major’不同
static constexpr unsigned int major = ARMA_VERSION_MAJOR;
^
RcppArmadillo.cpp:26:40: 错误:出现在类外的‘constexpr const unsigned int arma::arma_version::major’的声明不是定义 [-fpermissive]
const unsigned int arma::arma_version::major;
^
RcppArmadillo.cpp:27:40: 错误:对‘arma::arma_version::minor’的重声明在‘constexp’方面
const unsigned int arma::arma_version::minor;
原因:
在使用install.packages("forecast")安装包时,R会搜索最新的相关的安装包进行安装,如果操作系统的版本较低与R包不兼容,就会出现编译等错误。
解决办法:
升级Linux(CentOS)系统版本,或,安装较低版本的R包
下载低版本R包:
http://cran.r-project.org/src/contrib/Archive/RcppArmadillo/
手动安装低版本R RcppArmadillo包:
wget https://cran.r-project.org/src/contrib/Archive/RcppArmadillo/RcppArmadillo_0.9.900.3.0.tar.gz
R CMD INSTALL -l /usr/lib64/R/library RcppArmadillo_0.9.900.3.0.tar.gz
===================================================================
CentOS 6.4:
[root@testtest software]# R CMD INSTALL -l /usr/lib64/R/library RcppArmadillo_0.9.600.4.0.tar.gz
* installing *source* package ‘RcppArmadillo’ ...
** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
checking whether the C++ compiler works... no
configure: error: in `/tmp/RtmpDaPmhu/R.INSTALL41a7c56321c/RcppArmadillo':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘RcppArmadillo’
* removing ‘/usr/lib64/R/library/RcppArmadillo’
安装成功:
R CMD INSTALL -l /usr/lib64/R/library RcppArmadillo_0.5.600.2.0.tar.gz