问题
RcppArmadillo is a dependency of a few packages I'm trying to install. I get this error on compilation of RcppArmadillo version 0.10.1.0.0 (which is what R automatically pulls from CRAN when it finds that RcppArmadillo is a dep):
RcppArmadillo.cpp:26:40: error: redeclaration 'arma::arma_version::major' differs in 'constexpr'
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: error: from previous declaration 'arma::arma_version::major'
static constexpr unsigned int major = ARMA_VERSION_MAJOR;
^
RcppArmadillo.cpp:26:40: error: declaration of 'constexpr const unsigned int arma::arma_version::major' outside of class is not definition [-fpermissive]
const unsigned int arma::arma_version::major;
^
RcppArmadillo.cpp:27:40: error: redeclaration 'arma::arma_version::minor' differs in 'constexpr'
const unsigned int arma::arma_version::minor;
^
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:32:33: error: from previous declaration 'arma::arma_version::minor'
static constexpr unsigned int minor = ARMA_VERSION_MINOR;
^
RcppArmadillo.cpp:27:40: error: declaration of 'constexpr const unsigned int arma::arma_version::minor' outside of class is not definition [-fpermissive]
const unsigned int arma::arma_version::minor;
^
RcppArmadillo.cpp:28:40: error: redeclaration 'arma::arma_version::patch' differs in 'constexpr'
const unsigned int arma::arma_version::patch;
^
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:33:33: error: from previous declaration 'arma::arma_version::patch'
static constexpr unsigned int patch = ARMA_VERSION_PATCH;
^
RcppArmadillo.cpp:28:40: error: declaration of 'constexpr const unsigned int arma::arma_version::patch' outside of class is not definition [-fpermissive]
const unsigned int arma::arma_version::patch;
^
make: *** [RcppArmadillo.o] Error 1
make: *** Waiting for unfinished jobs....
ERROR: compilation failed for package 'RcppArmadillo'
* removing '/usr/local/lib64/R/library/RcppArmadillo'
* restoring previous '/usr/local/lib64/R/library/RcppArmadillo'
Error: Failed to install 'unknown package' from URL:
(converted from warning) installation of package 'RcppArmadillo' had non-zero exit status
Execution halted
FATAL: post proc: exit status 1
FATAL: While performing build: while running engine: exit status 255
This is being built inside of a Singuarity container in R 3.6.0 and with GCC 4.8.5 on CentOS 7. I can install version 0.9.900.3.0 of RcppArmadillo fine with the "install_version" command from devtools (and this version has completely worked fine before with the same other packages, which is why it's the one I'm trying to install), however, R immediately updates it to version 0.10.1.0.0 whenever another package I'm installing needs RcppArmadillo as a dependency, which then causes the error above and my build to fail. I haven't been able to find a way to stop R from doing this short of just telling it to not install dependencies for certain packages at all, but this poses headaches and I wanted to see if there was an easier solution here. Does anyone know how to fix this compilation error or how to keep R from automatically updating the package on install of another package that needs it?
Here's the part of the output showing the update happening right after version 0.9.900.3.0 of RcppArmadillo is successfully installed:
* DONE (RcppArmadillo)
Downloading package from url: https://ftp.osuosl.org/pub/cran/src/contrib/gratia_0.4.1.tar.gz
RcppArmad... (0.9.900.3.0 -> 0.10.1.0.0) [CRAN]
mvnfast (NA -> 0.2.5.1 ) [CRAN]
patchwork (NA -> 1.0.1 ) [CRAN]
Installing 3 packages: RcppArmadillo, mvnfast, patchwork
trying URL 'https://ftp.osuosl.org/pub/cran/src/contrib/RcppArmadillo_0.10.1.0.0.tar.gz'
回答1:
That has been discussed a few times before at the GitHub repo, or the mailing list, or here.
Your simplest bet is to pick an updated version via
install.packages("RcppArmadillo", repos="https://rcppcore.github.io/drat")
As this does not affect any of the systems CRAN (or most users) deploy, it is likely not worth a new upload (and all the associated hassle). You maight want to consider moving on from CentOS 7 if you have a choice in that matter.
来源:https://stackoverflow.com/questions/64652764/cannot-compile-rcpparmadillo