[Rcpp-devel] New to Rcpp - Can't get models to work

romain at r-enthusiasts.com romain at r-enthusiasts.com
Sun Feb 26 14:47:03 CET 2012


Hello,

If you are using R CMD SHLIB/dyn.load, you can grab the result of dyn.load and use it as the PACKAGE argument of Module. 

Romain

Le 23 févr. 2012 à 17:36, Kevin Ceder <thuja at uw.edu> a écrit :

> I started digging to Rcpp yesterday as a way to plug a C++ class I wrote into R.  It looks like RCPP_MODULE is the way to go to expose the class.  However, while following the examples I can't get the modules to initialize.
> 
> I take the code from the first example in the Rcpp-Modules vignette:
> #include "Rcpp.h"
> 
> using namespace Rcpp;
> 
> double norm( double x, double y ) {
> return sqrt( x*x + y*y );
> }
> RCPP_MODULE(mod) {
> function( "norm", &norm );
> }
> and compile into norm.dll.   Turning to R I use (following the example):
> 
>> require(Rcpp)
>> mod <- Module("mod")
>> mod$(3,4)
> and get an error from R:
> Error in Module(module, mustStart = TRUE) : 
>  Failed to initialize module pointer: Error in FUN("_rcpp_module_boot_mod"[[1L]], ...): no such symbol _rcpp_module_boot_mod in package .GlobalEnv
> 
> Any thoughts on where I'm going wrong here?
> 
> System info: Windows 7, R 2.14.1, Rcpp 0.9.10.
> 
> TIA,
> 
> kevin
> 
> "There is nothing - absolutely nothing - half so much worth doing as simply messing about in boats."
>        ~Ratty (from Kenneth Grahame's, The Wind in the Willows)
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Kevin R. Ceder
> PhD Candidate
> Stand Management Cooperative
> School of Forest Resources
> College of the Environment
> University of Washington
> Box 352100
> Seattle, WA 98195
> Phone: 206.543.0827
> Fax: 206.685.0790
> E-mail: thuja at uw.edu
> 
> 
> _______________________________________________
> 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


More information about the Rcpp-devel mailing list