Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal error: RcppEigen.h: No such file or directory

Tags:

r

rcpp

I am very new to Rcpp and RcppEigen probably this is why i can not figute it out myself:

I just want to write a c++ function that includes the Eigen library. To test if it workes i took the following example from http://people.math.aau.dk/~sorenh/misc/Rdocs/Rcpp/RcppSHLIB.pdf:

#include <Rcpp.h>
#include <RcppEigen.h>
RcppExport SEXP C_spdinv_eigen ( SEXP X_ ){
using Eigen::Map;
using Eigen::MatrixXd;
typedef Eigen::Map<Eigen::MatrixXd> MapMatd;
const MapMatd X(Rcpp::as<MapMatd>(X_));
const MatrixXd Xinv(X.inverse());
return(Rcpp::wrap(Xinv));
}

But i get the following error:

rcpp-test.cpp:2:23: fatal error: RcppEigen.h: No such file or directory
compilation terminated.
make: *** [rcpp-test.o] Error 1
g++ -I/usr/share/R/include -DNDEBUG    -I"/usr/local/lib/R/site-library/Rcpp/include"    -fpic  -O3 -pipe  -g  -c rcpp-test.cpp -o rcpp-test.o 
Error in Rcpp::sourceCpp("rcpp-test.cpp") : 
  Error 1 occurred building shared library.

Compiling a script that only has the #include <Rcpp.h> is working perfectly. The RcppEigen.h-file in located in the /usr/local/lib/R/site-library/RcppEigen/include directory. I tried installing RcppEigen with R CMD INSTALL ... and install.package: neither worked.

My seccionInfo is

R version 3.0.2 (2013-09-25)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C         LC_TIME=C            LC_COLLATE=C         LC_MONETARY=C       
 [6] LC_MESSAGES=C        LC_PAPER=C           LC_NAME=C            LC_ADDRESS=C         LC_TELEPHONE=C      
[11] LC_MEASUREMENT=C     LC_IDENTIFICATION=C 

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] RcppEigen_0.3.2.1.1 Rcpp_0.11.1        

loaded via a namespace (and not attached):
[1] Matrix_1.1-1.1  grid_3.0.2      lattice_0.20-27 tools_3.0.2    

Thanks for any help!

like image 563
Rentrop Avatar asked Mar 21 '23 03:03

Rentrop


1 Answers

You did not say how you attempted to compile your function. It matters:

  • In a package, use LinkingTo: RcppEigen.

  • In a function used with Rcpp Attributes, use a proper Rcpp::depends(RcppEigen).

There are numerous examples here, at the Rcpp Gallery and other places. Follow them, but follow all steps. Right now you have the compiler telling you that RcppEigen is unknown.

My Rcpp book details build issues in Chapter 2.

like image 132
Dirk Eddelbuettel Avatar answered Mar 31 '23 23:03

Dirk Eddelbuettel