[Rd] Newbie Rccp module question. "Failed to initialize module pointer"???

Dirk Eddelbuettel edd at debian.org
Thu Feb 17 20:14:29 CET 2011


Hi Andre,

Please consider posting on rcpp-devel for Rcpp-related questions.

On 17 February 2011 at 10:29, Andre Zege wrote:
| Hi all. I started looking at Rcpp, which looks pretty great, actually. At the 
| moment just trying to compile a module to get a feel how it all works without 
| fully understanding how all the pieces fit together. 
| 
| 
| Basically, i took the first example from Rcpp modules vignette: 
| 
| fun.cpp 
| ======================== 
| #include <Rcpp.h> 
| #include <math.h> 
| 
| using namespace Rcpp; 
| 
| double norm(double x, double y){ 
|   return sqrt(x*x+y*y); 
| } 
| 
| RCPP_MODULE(mod){ 
|   function("norm", &norm); 
| } 
| ========================== 
| 
| I then run Rcpp.package.skeleton("mypackage"), put fun.cpp in mypackage/src and 
| did 
| 
| R CMD INSTALL mypackage, which seemed to compile mypackage.so OK. However, when 
| i am trying  to use module, i get error message.  Namely, after i run R and do 
| 
| >library("Rcpp") 
| >library("mypackage") 
| > mod<-Module("mod") 

You may want to try

    mod <- new( mod )
    bdtMod <- Module( "bdt" )			# get the module code
    bdt <- new( bdtMod$date )                  	# date class default constructor for reference instance

| >mod$norm(3,4) 
| 
| i get the following 
| 
| 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 

Hm. Not sure what is going there. I can run it via inline as a quick test:

R> inc <- '
+ double norm(double x, double y){
+   return sqrt(x*x+y*y);
+ }
+ 
+ RCPP_MODULE(mod){
+   function("norm", &norm);
+ }
+ '
R> fx <- cxxfunction( signature(), "" , include = inc, plugin = "Rcpp" )
R> mod <- Module( "mod", getDynLib(fx) )
R> mod$norm(3,4)
[1] 5
R> mod
Rcpp module 'mod' 
	1 functions: 
           norm : 2 arguments

	0 classes : 
R>  
| I am pretty sure my error is a pretty obvious one, could someone give me a 
| pointer on what to do differently or where to look for reference. Literal search 
| for the error message doesn't bring anything useful.

What is your version?  What is your OS?

We just released Rcpp 0.9.1 a few days ago so I have been running a lot of
tests some of which include building and loading modules.  This "should have
worked" for you.

Again, follow-ups on rcpp-devel which I'll CC will be appreciated. You'd have
to sign up there to post.

Thanks, Dirk

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



More information about the R-devel mailing list