[Rcpp-devel] Problem with modules

Dirk Eddelbuettel edd at debian.org
Thu Sep 4 19:14:32 CEST 2014


On 4 September 2014 at 11:58, Dirk Eddelbuettel wrote:
| 
| On 4 September 2014 at 18:28, Stefan Boehringer wrote:
| | I try to get the Rcpp.package.skeleton example running.
| 
| My favourite approach for cases like this is to look at existing / working
| packages.  We do have an example in the unit tests set in 
| 
|            inst/unitTests/testRcppModule/
| 
| and its ...
| 
| | Rcpp.package.skeleton('GeneticsHaplotype', module = T);
| | 
| | My zzz.R looks like:
| | 
| | .onLoad <- function(libname, pkgname){
| |     #loadRcppModules()
| |     loadModule("yada", TRUE)
| | }
| 
| ... file inst/unitTests/testRcppModule/R/zzz.R does
| 
| .onLoad <- function(libname, pkgname){
|     loadRcppModules()
| }
| 
| Can you try this?  
| 
| If the skeleton does loadModule(...) maybe the skeleton code is behind which
| I could fix.
| 
| | I also tried various variations (as indicated by the comments in zzz.R).
| | I run into
| | 
| | library('devtools');
| | library('Rcpp');
| | install('GeneticsHaplotype');
| | require('GeneticsHaplotype')
| | y = Module('yada', mustStart = T);
| 
| (Aside: You don't need trailing ';', and you surely do not need devtools.)
| 
| There are a number of other packages on CRAN using modules, some with
| classes, some with free functions, ... so it is worth looking around.

Looks like most of mine do the 

   loadModule("nameofmodule", TRUE)

approach. And looking at the zzz.R which the skeleton generator copies, it is
what you should do:


   ## Up until R 2.15.0, the require("methods") is needed but (now)
   ## triggers an warning from R CMD check
   #.onLoad <- function(libname, pkgname){
   #    #require("methods")  ## needed with R <= 2.15.0
   #    loadRcppModules()
   #}
   
   
   ## For R 2.15.1 and later this also works. Note that calling loadModule() triggers
   ## a load action, so this does not have to be placed in .onLoad() or evalqOnLoad().
   loadModule("NumEx", TRUE)
   loadModule("yada", TRUE)
   loadModule("stdVector", TRUE)


In fact, loadModule() is a free function you can call "whereever" as opposed
to in .onLoad() -- we owe that improvement to a contribution from John
Chambers a while back.  

So it looks like the documentation is fine.

Dirk


| 
| Dirk
|  
| | into
| | 
| | Error in Module("yada", mustStart = T) :
| |   Failed to initialize module pointer: Error in
| | FUN("_rcpp_module_boot_yada"[[1L]], ...): no such symbol
| | _rcpp_module_boot_yada in package .GlobalEnv
| | 
| | 
| | I am running R 3.1.1 (also tried 3.0.1, then 3.0.3), Rcpp_0.11.2
| | 
| | In earlier tries the package name was prepended to the function in the
| | error message, but I could never get to that point again.
| | 
| | Thank you very much in advance,
| | 
| |     Stefan
| | 
| | _______________________________________________
| | Rcpp-devel mailing list
| | Rcpp-devel at lists.r-forge.r-project.org
| | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
| 
| -- 
| http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list