Search code examples
rrcpparmadillor-packageroxygen2

NAMESPACE option created by RcppArmadillo.package.skeleton causes error


I'm creating a R package that contains Rcpp functions depending on RcppArmadillo, so I first generate the package skeleton by RcppArmadillo.package.skeleton. However, when I roxygenize my package, it gives me an error shown below.

R code

library(roxygen2)
library(RcppArmadillo)
library(Rcpp)
RcppArmadillo.package.skeleton(name = "prac_181206", example_code = FALSE)
roxygenize(package.dir =  "prac_181206", roclets = "rd")

Error

Error in getDLLRegisteredRoutines.DLLInfo(dll, addNames = FALSE) : 
  must specify DLL via a “DLLInfo” object. See getLoadedDLLs()

After spending some time, I figured out this can be solved by removing .registration option in NAMESPACE file given as follows.

Original NAMESPACE file

useDynLib(prac_181206, .registration=TRUE)
importFrom(Rcpp, evalCpp)
exportPattern("^[[:alpha:]]+")

In short, after changing the first line above to useDynLib(prac_181206), it works fine, but I don't understand what the error means and why my solution works.

Could you anyone help me with this matter? I appreciate it!

Because this is a toy example, hopefully reproducible, I didn't include any other functions in man or src folders created by RcppArmadillo.package.skeletonabove.

FYI, the relevant information about my platform is

  • Windows 7 x64
  • R-3.5.1, Rstudio-1.1.423
  • Rcpp-0.12.19, RcppArmadillo-0.9.100.5.0
  • roxygen2-6.1.1

Solution

  • That is, as best as I can tell, roxygen2 issue ticket #771 which I filed on August 3, and which is still unresolved. Despite the roxygen2 team closing it. Feel free to follow-up there.

    If one use roxygen2 6.0.1 it works:

    edd@rob:/tmp$ r -lRcppArmadillo -e'RcppArmadillo.package.skeleton(name = "prac_181206", example_code = FALSE)'
    
    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 './prac_181206/Read-and-delete-me'.
    
    Adding pkgKitten overrides.
    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
    edd@rob:/tmp$ cd prac_181206/
    edd@rob:/tmp/prac_181206$ roxy.r 
    ** Using cached version 6.0.1 of roxygen2.
    First time using roxygen2. Upgrading automatically...
    Updating roxygen version in /tmp/prac_181206/DESCRIPTION
    Loading required package: Rcpp
    edd@rob:/tmp/prac_181206$ 
    

    where roxy.r is this simple wrapper that hard-wires roxygen2 6.0.1.