rrcpprcppeigen

Where should RcppEigen be in description file


  1. I'm unsure how to only put RcppEigen under the LinkingTo and not the Imports headers. I've gotten conflicting instructions and am very confused what to do. I've been learning how to use Eigen myself, so I'm not sure if I did something wrong in writing the functions. I've seen Do I need to import RccpEigen in the DESCRIPTION file for an R package using it, or is "LinkingTo" enough? and understand it should be only under LinkingTo according to the CRAN manual https://cran.r-project.org/doc/manuals/R-exts.html#:~:text=Specifying%20a%20package%20in%20%E2%80%98LinkingTo%E2%80%99%20suffices%20if%20these%20are%20C/C%2B%2B%20headers%20containing%20source%20code
  2. Should my code using RcppEigen be in header files or .cpp files? My understanding was that .h was just for empty definitions of the functions if you need to use it in other cpp files, and .cpp was for the implementation of those functions. Right now I've been using .cpp and #include <RcppEigen.h> and letting Rcpp generate the required RcppExports.cpp files

I've tried testing the package with devtools::check_win_devel() since that's what CRAN does and got the reply:

"Package in Depends/Imports which should probably only be in LinkingTo: ‘RcppEigen’".

So accordingly, I removed RcppEigen from the Imports and left it in the LinkingTo section, but now the package fails the R CMD check --as-cran with:

"Namespace dependency missing from DESCRIPTION Imports/Depends entries: 'RcppEigen'

See section 'The DESCRIPTION file' in the 'Writing R Extensions' manual."

Is there something wrong with how I'm accessing the Eigen objects?


Solution

  • Thanks to @Roland, I found out that my NAMESPACE had an import(RcppEigen) in it which was coming from a file along the path R\<packagename>-package.R that had this in it:

    ## usethis namespace: start
    #' @import RcppEigen
    ## usethis namespace: end
    NULL
    

    By removing the import line, I was able to just put RcppEigen into LinkingTo