RcppCore / RcppArmadillo

Rcpp integration for the Armadillo templated linear algebra library
193 stars 55 forks source link

ERROR: compilation failed for package ‘RcppArmadillo’ #457

Closed dd315 closed 1 week ago

dd315 commented 4 weeks ago

I'm sorry, I've been trying very hard to solve my problem

sudo apt install r-cran-rcpparmadillo sudo apt install r-base-dev

The above two commands did not work

Sys.info ubuntu 22.04 R 4.4.1

* installing *source* package ‘RcppArmadillo’ ...
** 成功将‘RcppArmadillo’程序包解包并MD5和检查
** using staged installation
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C++... yes
checking whether g++ -std=gnu++17 accepts -g... yes
checking for g++ -std=gnu++17 option to enable C++11 features... none needed
checking how to run the C++ preprocessor... g++ -std=gnu++17 -E
checking whether the compiler supports GNU C++... (cached) yes
checking whether g++ -std=gnu++17 accepts -g... (cached) yes
checking for g++ -std=gnu++17 option to enable C++11 features... (cached) none needed
checking whether we have a suitable tempdir... /tmp
checking whether R CMD SHLIB can already compile programs using OpenMP... yes
checking LAPACK_LIBS... system LAPACK found
configure: creating ./config.status
config.status: creating inst/include/RcppArmadillo/config/RcppArmadilloConfigGenerated.h
config.status: creating src/Makevars
** libs
using C++ compiler: ‘g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I'/usr/local/lib/R/site-library/Rcpp/include'    -fopenmp -fpic  -g -O2 -ffile-prefix-map=/build/r-base-2y82rL/r-base-4.4.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2   -c RcppArmadillo.cpp -o RcppArmadillo.o
In file included from /usr/local/lib/R/site-library/Rcpp/include/Rcpp/routines.h:26,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:128,
                 from ../inst/include/RcppArmadillo/interface/RcppArmadilloForward.h:25,
                 from ../inst/include/RcppArmadillo/Lighter:34,
                 from RcppArmadillo.cpp:21:
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/iostream/Rstreambuf.h: In member function ‘std::streamsize Rcpp::Rstreambuf<OUTPUT>::xsputn(const char*, std::streamsize) [with bool OUTPUT = true; std::streamsize = long int]’:
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/iostream/Rstreambuf.h:53:20: warning: field precision specifier ‘.*’ expects argument of type ‘int’, but argument 2 has type ‘std::streamsize’ {aka ‘long int’} [-Wformat=]
   53 |         Rprintf("%.*s", num, s);
      |                  ~~^~   ~~~
      |                    |    |
      |                    int  std::streamsize {aka long int}
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/iostream/Rstreambuf.h: In member function ‘std::streamsize Rcpp::Rstreambuf<OUTPUT>::xsputn(const char*, std::streamsize) [with bool OUTPUT = false; std::streamsize = long int]’:
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/iostream/Rstreambuf.h:57:21: warning: field precision specifier ‘.*’ expects argument of type ‘int’, but argument 2 has type ‘std::streamsize’ {aka ‘long int’} [-Wformat=]
   57 |         REprintf("%.*s", num, s);
      |                   ~~^~   ~~~
      |                     |    |
      |                     int  std::streamsize {aka long int}
In file included from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:181,
                 from ../inst/include/RcppArmadillo/interface/RcppArmadilloForward.h:25,
                 from ../inst/include/RcppArmadillo/Lighter:34,
                 from RcppArmadillo.cpp:21:
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/print.h: In function ‘void Rcpp::warningcall(SEXP, const string&)’:
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/print.h:30:19: error: format not a string literal and no format arguments [-Werror=format-security]
   30 |     Rf_warningcall(call, s.c_str());
      |     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
cc1plus: some warnings being treated as errors
make: *** [/usr/lib/R/etc/Makeconf:204:RcppArmadillo.o] 错误 1
ERROR: compilation failed for package ‘RcppArmadillo’
* removing ‘/home/hewei/R/x86_64-pc-linux-gnu-library/4.4/RcppArmadillo’
Warning in install.packages :
  安装程序包‘RcppArmadillo’时退出狀態的值不是0
eddelbuettel commented 4 weeks ago

One at a time please. Why did sudo apt install r-cran-rcpparmadillo not work? What were the errors?

For the second, we need actual sessionInfo() output for your compiler etc. RcppArmadillo very much works on Ubuntu down to 22.04 and further. (Running 24.04 on several machines here.)

eddelbuettel commented 4 weeks ago

I think you may have an outdated Rcpp here, it needs at update (as current versions have) related to the print format string. For what it is worth I just installed a current Rcpp (1.0.13) pulled in by a current RcppArmadillo (14.0.2-1) on Ubuntu 22.04, both from source. No issues.

So please ensure all required components are current.

dd315 commented 3 weeks ago

I think you may have an outdated Rcpp here, it needs at update (as current versions have) related to the print format string. For what it is worth I just installed a current Rcpp (1.0.13) pulled in by a current RcppArmadillo (14.0.2-1) on Ubuntu 22.04, both from source. No issues.

So please ensure all required components are current.

Thank you very much for your reply! I am a new R user and I successfully installed RcppArmadillo after updating Rcpp! Best wishes.

eddelbuettel commented 3 weeks ago

and I successfully installed RcppArmadillo after updating Rcpp

I should probably impose a (correct and needed, as we have seen again here) minimum Rcpp version in the DESCRIPTION files of RcppArmadillo. That may have too be 1.0.13. I will ponder this.

eddelbuettel commented 3 weeks ago

From looking at the NEWS file for Rcpp we seem to have made that format string change for release 1.0.12 which would then be a suitable minimal version.

Do you know which version you upgraded from here?

eddelbuettel commented 1 week ago

Closing this as RcppArmadillo 14.2.0-1 now specified Rcpp (>= 1.0.12).