0

I am trying to depend on RcppArmadillo in my package but I get an error unable to load shared object /tmp/Rtmp0LswYZ/Rinst82cbed4eaee/00LOCK-alt.raster/00new/alt.raster/libs/alt.raster.so: undefined symbol: dsyev_ when I try to run the command R CMD build . in my package directory. However, following the instructions on https://stackoverflow.com/a/14165455 in an interactive R session works correctly. I have also run the R -e 'Rcpp::compileAttributes()' in my package directory and it seems to generate the RcppExports.cpp correctly. What am I doing wrong?

Vijay
  • 151
  • 1
  • 11
  • 1
    We need a minimally complete verifiable example to help you. – Dirk Eddelbuettel Jul 15 '20 at 02:20
  • If I have to guess your `src/Makevars` lacks the LAPACK BLAS link instructions. Compare with what RcppArmadillo.package.skeleton() generates. – Dirk Eddelbuettel Jul 15 '20 at 02:22
  • https://drive.google.com/file/d/1NhYGShKXKAtda0zZRM4JOsCNdWZPzioM/view?usp=sharing contains a minimum example of my setup. Please let me know if there's another way to share this. Thanks for your help. – Vijay Jul 15 '20 at 03:17
  • I only browsed but no `src/Makevars` -- take a look at this one also present in a large number of actual working packages: https://github.com/RcppCore/RcppArmadillo/blob/master/inst/skeleton/Makevars Line 14 is what you're missing, line 13 probably won't hurt so just copy it in. – Dirk Eddelbuettel Jul 15 '20 at 03:22

1 Answers1

4

As surmised in the comments above, it is really beneficial to start from a working example.

To create one, we offer the RcppArmadillo.package.skeleton() function. Use it as follows:

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$ 

It should create these files:

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$ 
Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725