尝试依赖 RcppAmadillo 时出现未定义符号错误

Undefined symbol error when trying to depend on RcppAmadillo

我试图依赖我的包中的 RcppArmadillo,但是当我尝试 运行 我的包目录中的命令 R CMD build . 时出现错误 unable to load shared object /tmp/Rtmp0LswYZ/Rinst82cbed4eaee/00LOCK-alt.raster/00new/alt.raster/libs/alt.raster.so: undefined symbol: dsyev_。但是,按照 在交互式 R 会话中的说明可以正常工作。我的包目录中也有 运行 R -e 'Rcpp::compileAttributes()',它似乎正确生成了 RcppExports.cpp。我做错了什么?

正如以上评论所推测的那样,从一个工作示例开始确实有益。

要创建一个,我们提供 RcppArmadillo.package.skeleton() 功能。使用方法如下:

edd@rob:/tmp$ Rscript -e 'RcppArmadillo::RcppArmadillo.package.skeleton("demoPkg")'

Calling kitten to create basic package.
Creating directories ...
Creating DESCRIPTION ...
Creating NAMESPACE ...
Creating Read-and-delete-me ...
Saving functions and data ...
Making help files ...
Done.
Further steps are described in './demoPkg/Read-and-delete-me'.

Adding pkgKitten overrides.
 >> added .gitignore file
 >> added .Rbuildignore file
Deleted 'Read-and-delete-me'.
Done.

Consider reading the documentation for all the packaging details.
A good start is the 'Writing R Extensions' manual.

And run 'R CMD check'. Run it frequently. And think of those kittens.


Adding RcppArmadillo settings
 >> added Imports: Rcpp
 >> added LinkingTo: Rcpp, RcppArmadillo
 >> added useDynLib and importFrom directives to NAMESPACE
 >> added Makevars file with Rcpp settings
 >> added Makevars.win file with RcppArmadillo settings
 >> added example src file using armadillo classes
 >> added example Rd file for using armadillo classes
 >> invoked Rcpp::compileAttributes to create wrappers
edd@rob:/tmp$ 

它应该创建这些文件:

edd@rob:/tmp$ tree demoPkg/
demoPkg/
├── DESCRIPTION
├── man
│   ├── demoPkg-package.Rd
│   ├── hello.Rd
│   └── rcpparma_hello_world.Rd
├── NAMESPACE
├── R
│   ├── hello.R
│   └── RcppExports.R
└── src
    ├── Makevars
    ├── Makevars.win
    ├── rcpparma_hello_world.cpp
    └── RcppExports.cpp

3 directories, 11 files
edd@rob:/tmp$