[Rcpp-devel] package .onLoad multiple modules
Dirk Eddelbuettel
edd at debian.org
Mon May 30 01:11:09 CEST 2011
On 30 May 2011 at 10:29, baptiste auguie wrote:
| Hi,
|
| On 30 May 2011 04:28, Dirk Eddelbuettel <edd at debian.org> wrote:
| >
| > On 29 May 2011 at 18:56, baptiste auguie wrote:
| > | Dear list,
| > |
| > | [Disclaimer: I am not very familiar with Rcpp/C++, and probably
| > | haven't followed all the relevant discussions on this list.]
| > |
| > | I'm trying to tidy up two packages on r-forge [*] before submitting
| > | them to CRAN. In "cda/zzz.r", I have the following code,
| > |
| > | NAMESPACE <- environment()
| > | cda <- new( "Module" )
| > | cdatests <- new( "Module" )
| > | cd <- new( "Module" )
| > | linear <- new( "Module" )
| > | array <- new( "Module" )
| > |
| > | .onLoad <- function(libname, pkgname){
| > | unlockBinding( "cda" , NAMESPACE )
| > | unlockBinding( "cdatests" , NAMESPACE )
| > | unlockBinding( "cd" , NAMESPACE )
| > | unlockBinding( "linear" , NAMESPACE )
| > | assign( "cda", Module( "cda" ), NAMESPACE )
| > | assign( "cdatests", Module( "cdatests" ), NAMESPACE )
| > | assign( "cd", Module( "cd" ), NAMESPACE )
| > | assign( "linear", Module( "linear" ), NAMESPACE )
| > | lockBinding( "cda", NAMESPACE )
| > | lockBinding( "cdatests", NAMESPACE )
| > | lockBinding( "cd", NAMESPACE )
| > | lockBinding( "linear", NAMESPACE )
| > |
| > | unlockBinding( "array" , NAMESPACE )
| > | assign( "array", Module( "array" ), NAMESPACE )
| > | lockBinding( "array", NAMESPACE )
| > |
| > | }
| > |
| > | It seems to work, but is there something I can/should do to make this
| > | a wee cleaner?
| >
| > Have another look at the Rcpp-modules vignette, and/or the third set of
| > slides ("Advanced Rcpp") from our class in April -- you no longer need the
| > unlockBinding / lockBinding business as Romain internalized that. The
| > skeleton-generated packages now just do this in zzz.R:
| >
| > .onLoad <- function(pkgname, libname){
| > loadRcppModules()
| > }
| >
| > using a 'RcppModules: cda, cdatests, cd, linear, array' declaration in
| > DESCRIPTION.
|
| Strange, this does not seem to work for me.
|
| If I use the following zzz.r, (with RcppModules listed in DESCRIPTION)
|
| .onLoad <- function(libname, pkgname){
| loadRcppModules()
| }
|
| I get a segfault whenever I use a c++ function,
|
| *** caught segfault ***
| address 0x0, cause 'memory not mapped'
|
| Traceback:
| 1: .External(list(name = "InternalFunction_invoke", address =
| <pointer: 0x101407f30>, dll = list(name = "Rcpp", path =
| "/Library/Frameworks/R.framework/Versions/2.13/Resources/library/Rcpp/libs/x86_64/Rcpp.so",
| dynamicLookup = TRUE, handle = <pointer: 0x101441030>,
| info = <pointer: 0x1002b3ed0>), numParameters = -1L), <pointer:
| 0x103011050>, ...)
| 2: circular_dichroism_spectrum(clust, gold, n = 1.33, N = 36, progress = FALSE)
| 3: onecluster()
|
| Is there another step I'm missing?
My first instinct is to check the unitTest, so look at what is different in
test run from
inst/unitTests/runit.Module.client.package.R
using
inst/unitTests/testRcppModule/
That should still work on your platform and you should be able to go from there.
Dirk
--
Gauss once played himself in a zero-sum game and won $50.
-- #11 at http://www.gaussfacts.com
More information about the Rcpp-devel
mailing list