致命错误:RcppEigen。h:没有这样的文件或目录。

时间:2022-06-05 22:56:12

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

我对Rcpp和RcppEigen很陌生可能这就是为什么我不能自己画出来的原因:

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:

我只是想写一个c++函数,其中包括了Eigen库。为了测试它是否工作,我从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.

编译只有#include 是完美的工作。RcppEigen。h文件位于/ usr/local/lib/r/site -library/RcppEigen/包含目录。我尝试安装RcppEigen和rcmd安装…和安装。包:既不工作。 的脚本。h>

My seccionInfo is

我的seccionInfo

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!

感谢任何帮助!

1 个解决方案

#1


3  

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

您没有说明您如何试图编译您的函数。重要:

  • In a package, use LinkingTo: RcppEigen.

    在一个包中,使用LinkingTo: RcppEigen。

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

    在使用Rcpp属性的函数中,使用适当的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.

这里有很多例子,在Rcpp画廊和其他地方。跟随他们,但要遵循所有的步骤。现在你让编译器告诉你RcppEigen是未知的。

My Rcpp book details build issues in Chapter 2.

我的Rcpp书籍详细介绍了第2章的问题。

#1


3  

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

您没有说明您如何试图编译您的函数。重要:

  • In a package, use LinkingTo: RcppEigen.

    在一个包中,使用LinkingTo: RcppEigen。

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

    在使用Rcpp属性的函数中,使用适当的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.

这里有很多例子,在Rcpp画廊和其他地方。跟随他们,但要遵循所有的步骤。现在你让编译器告诉你RcppEigen是未知的。

My Rcpp book details build issues in Chapter 2.

我的Rcpp书籍详细介绍了第2章的问题。