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

Dirk Eddelbuettel edd at debian.org
Thu Feb 23 18:02:33 CET 2012


Hi Kevin,

Welcome to Rcpp!

On 23 February 2012 at 08:36, Kevin Ceder wrote:
| 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.  

You say "and compile into norm.dll" -- the 'how' is important. You need to do
more than just saying 'R CMD SHLIB'. The Rcpp modules vignettes has details.

| 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?

Hard to say from what you post but every example posted in the vignette
should work, either via inline or via a package generated with the skeleton
generator.

Dirk
 
| 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

-- 
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx


More information about the Rcpp-devel mailing list