Cannot compile sheet with armadillo examples

I am trying to compile an Rarmadillo example with Rinside and I keep getting:

In file included from rinside_arma0.cpp:8:0: /usr/local64/opt/R-2.15.2/lib/R/library/RcppArmadillo/include/RcppArmadillo.h:26:6: error: #error "The file 'Rcpp.h' should not be included. Please correct to include only 'RcppArmadillo.h'." 

I googled, but I keep getting the source code as such. Any ideas?

Code:

 // -*- c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- // // Simple example using Armadillo classes // // Copyright (C) 2012 Dirk Eddelbuettel and Romain Francois #include <RInside.h> // for the embedded R via RInside #include <RcppArmadillo.h> int main(int argc, char *argv[]) { RInside R(argc, argv); // create an embedded R instance std::string cmd = "diag(3)"; // create a Matrix in r arma::mat m = Rcpp::as<arma::mat>(R.parseEval(cmd)); // parse, eval + return result std::cout << m << std::endl; // and use Armadillo i/o exit(0); } 

and compiled it using:

 g++ -I/usr/local64/opt/R-2.15.2/lib/R/include -I/usr/local64/opt/R-2.15.2/lib/R/library/Rcpp/include -I"/usr/local64/opt/R-2.15.2/lib/R/library/RcppArmadillo/include" -I/usr/local64/opt/R-2.15.2/lib/R/library/RInside/include -g -O2 -Wall -I/usr/local/include rinside_arma0.cpp -L/usr/local64/opt/R-2.15.2/lib/R/lib -lR -lf77blas -latlas -llapack -L/usr/local64/opt/R-2.15.2/lib/R/library/Rcpp/lib -lRcpp -Wl,-rpath,/usr/local64/opt/R-2.15.2/lib/R/library/Rcpp/lib -L/usr/local64/opt/R-2.15.2/lib/R/library/RInside/lib -lRInside -Wl,-rpath,/usr/local64/opt/R-2.15.2/lib/R/library/RInside/lib -o rinside_arma0 
+4
source share
1 answer

You get an error because Rcpp.h turned on before RcppArmadillo.h , Rcpp.h turned on RInside.h .

For the magic that RcppArmadillo gives, the RcppArmadillo file must be uploaded to Rcpp.h Therefore, I suggest you do this:

 #include <RcppArmadillo.h> #include <RInside.h> 
+9
source

Source: https://habr.com/ru/post/1489696/


All Articles