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

Andre Zege azege at yahoo.com
Thu Feb 17 19:29:50 CET 2011


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") 
>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 



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.



More information about the R-devel mailing list