[Rcpp-devel] RcppProgress RcppArmadillo

Dirk Eddelbuettel edd at debian.org
Tue Aug 13 14:17:21 CEST 2013


On 13 August 2013 at 13:50, bbonit at tin.it wrote:
|  Dear list good morning,
|  can someone explain why the compiler return me an error when I add the
| following include
| #include <progress.hpp> (without this inclusion the code is compiled in correct
| way)

I don't fully understand. If it is correct without it, but breaks with it --
then why do you bother including it?

| (using // [[Rcpp::depends(Rcpp,RcppArmadillo,RcppProgress)]] for dependencies)
| 
| the example code (using attributes sourceCpp) :
| 
| 
| // [[Rcpp::depends(Rcpp,RcppArmadillo,RcppProgress)]]
|
| #include <RcppArmadillo.h>
| #include <RcppArmadilloExtensions/sample.h>
| 
| #include <progress.hpp>
| 
| 
| // [[Rcpp::export]]
| 
| arma::vec Mahalanobis(arma::mat x, arma::rowvec center, arma::mat cov){
|     int n = x.n_rows;
|     arma::mat x_cen;
|     x_cen.copy_size(x);
|     for (int i=0; i < n; i++) {
|         x_cen.row(i) = x.row(i) - center;
|     }
|     return sum((x_cen * cov.i()) % x_cen, 1);   
| }
| 
| 
| require("Rcpp")
| Sys.setenv("PKG_CXXFLAGS"="-fopenmp")
| Sys.setenv("PKG_LIBS"="-fopenmp")
|  sourceCpp("rr.cpp")
| 
| 
| ERROR :
| g++ -m32 -I"C:/PROGRA~1/R/R-30~1.1/include" -DNDEBUG     -I"C:/Users/gianni/
| Documents/R/win-library/3.0/Rcpp/include" -I"C:/Users/gianni/Documents/R/
| win-library/3.0/RcppArmadillo/include" -I"C:/Users/gianni/Documents/R/
| win-library/3.0/RcppProgress/include"  -I"d:/RCompile/CRANpkg/extralibs64/local
| /include"  -fopenmp   -O2 -Wall  -mtune=core2 -c rr.cpp -o rr.o In file
| included from rr.cpp:10:0: C:/Users/gianni/Documents/R/win-library/3.0/
| RcppProgress/include/progress.hpp: In constructor 'Progress::Progress(long
| unsigned int, bool)': C:/Users/gianni/Documents/R/win-library/3.0/RcppProgress/
| include/progress.hpp:27:84: error: 'error' was not declared in this scope make:
| *** [rr.o] Error 1
| Errore in sourceCpp("rr.cpp") : Error 1 occurred building shared library.

The R API (in C) uses renaming defines, so "error()" is sometimes / used to
be "Rf_error()".

I presume that the include order you have here has something to do with this:
one file may have undefined it.  It may be as simple as moving the include
for progress.hpp _above_ the othres.

But what you have is more difficult to debug than it needs to be. I would try
from just Rcpp, and adding one component at a time.

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list