Romain:

Thanks for your helpful response.  This works perfectly.

Michael



On Feb 26, 2012, at 8:50 AM, <rom...@r-enthusiasts.com>
 <rom...@r-enthusiasts.com> wrote:

> hello, 
> 
> You can grab the result of dyn.load and use it as the PACKAGE argument of 
> Module. 
> 
> Romain
> 
> 
> Le 26 févr. 2012 à 01:11, Michael Braun <bra...@mit.edu> a écrit :
> 
>> No, what I would like to do is access an Rcpp module from a dynamic library 
>> that is not part of a R package (e.g., loaded using dyn.load() ).  If I put 
>> the code in a package, there is no problem.  But what I am getting is:
>> 
>>> library(Rcpp)
>>> dyn.load("add.so")
>>> mod=Module("adding")
>>> add=new(mod$adding,1.2,3.4)
>> Error in Module(module, mustStart = TRUE) : 
>> Failed to initialize module pointer: Error in 
>> FUN("_rcpp_module_boot_adding"[[1L]], ...): no such symbol 
>> _rcpp_module_boot_adding in package .GlobalEnv
>> 
>> The packages that you reference are all, well, packages, and from what I can 
>> tell about .onLoad(), that applies only to packages.  And the 
>> loadRcppModules function, apparently, must be called from an .onLoad 
>> function (because I get an error message to that effect).
>> 
>> I have never had a problem loading compiled functions this way; it appears 
>> to be only an issue with modules.
>> 
>> I would appreciate some helpful suggestions from anyone in R-land who may 
>> have had some success with this (e.g., specific documentation pages to look 
>> at, code snippets that have worked for others, or other useful suggestions 
>> on what to try next).  Of course, if what I want to do is known to be 
>> impossible, that would also be a helpful response. 
>> 
>> Respectfully,
>> 
>> Michael
>> 
>> 
>> On Feb 25, 2012, at 3:24 PM, Dirk Eddelbuettel wrote:
>> 
>>> 
>>> Hi Michael,
>>> 
>>> On 25 February 2012 at 19:45, Michael Braun wrote:
>>> | Hi.  I would like to start using Rcpp modules in my code, but I am having 
>>> some
>>> | trouble loading them into R.  Here is an example:
>>> 
>>> My personal approach is to follow the path of least resistance on __start
>>> from an existing package__ having the feature I want to use.
>>> 
>>> Rcpp comes with modules-using packages as part of the documentation (Rcpp
>>> modules vignette) and unit tests. And there is even a package skeleton
>>> generator (for which you can set an option to use modules). 
>>> 
>>> And among the now 55 CRAN packages using Rcpp (!!), a few use modules
>>> too. One is my RcppBDT package, there are the two packages by Baptiste (cda,
>>> planar) and probably a few more but one can't tell from the DESCRIPTION.
>>> 
>>> Your code may have been fine, but you also need to look at the .onLoad or
>>> .onAttach function etc.  So starting from a working stanza really strikes me
>>> as easiest.
>>> 
>>> Hth, Dirk
>>> 
>>> -- 
>>> "Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
>>> dark to read." -- Groucho Marx
>> 
>> 
>> 
>> _______________________________________________
>> Rcpp-devel mailing list
>> Rcpp-devel@lists.r-forge.r-project.org
>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Michael Braun 
MIT Sloan School of Management
bra...@mit.edu
-------------------------------------------------- 
View my research at
http://braunm.scripts.mit.edu/

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to