Quantcast

Newbie Rccp module question. "Failed to initialize module pointer"???

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Newbie Rccp module question. "Failed to initialize module pointer"???

Andre Zege
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Newbie Rccp module question. "Failed to initialize module pointer"???

Dirk Eddelbuettel

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 | [hidden email] | http://dirk.eddelbuettel.com

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Newbie Rccp module question. "Failed to initialize module pointer"???

A Zege
Dirk, thanks for your reply. I posted my answer right away and went on vacation. My post was pending since then. Still cannot post, so I opened another profile -- maybe this time it gets through.

To answer your questions, I run  R-2.12.1 on 64 bit RedHat Linux on Xeon machine.
What seems odd that the error message i am getting refers to .GlobalEnv package. The symbol it is looking for, _rcpp_module_boot_mod, is in shared library for my package, i checked it with nm. Is there any doc on how modules are implemented?
Loading...