Hi Dirk, Thank You for the quick reply.
After reading many posts, I found your suggestion works: > R.version.string [1] "R version 2.13.1 (2011-07-08)" > require(Rcpp) > dl <- dyn.load("mod.so") > mod <- Module("mod",PACKAGE=dl) > mod$norm(1,2) [1] 2.236068 On 05/08/2012 06:14 PM, Dirk Eddelbuettel wrote:
Hi James, On 8 May 2012 at 17:51, James Simone wrote: | I have followed the Rcpp developer's recommendation that a package | greatly simplifies using RCPP_MODULE wrappering. Unfortunately, I'm | having difficulty building and checking even a simple package | containing an Rcpp module. I have read previous posts on this topic | but I did not find anything helpful. I must be overlooking something | very simple, please help. You did the right thing. Unfortunately, things are a little bit in flux right now as some of the related 'module loading' code got changed recently, and not all pieces have been put together right. I am flipping back and forth between our current SVN version and the most recent release 0.9.10, but I fear that 0.9.10 isn't quite right with R 2.15.0. To make matters worse, Romain appears to be mostly off email right now. So I don't have an immediate fix. Modules loading should get better with R 2.15.1 making it simpler than the zzz.R you have below -- but in the meantime you may have to resort to non-Modules code for Rcpp. Sorry, Dirk | The package check fails with this error: | ** testing if installed package can be loaded | Error : .onLoad failed in loadNamespace() for 'mod', details: | call: value[[3L]](cond) | error: failed to load module mod from package mod | no binding for "norm" | | The package skeleton was created with Rcpp.package.skeleton() to which | I added a C++ source file and then edited files according to the | 'Read-and-delete-me' file. | | Here are my build and check steps: | | $ R CMD build mod | * checking for file `mod/DESCRIPTION' ... OK | * preparing `mod': | * checking DESCRIPTION meta-information ... OK | * cleaning src | * checking for LF line-endings in source and make files | * checking for empty or unneeded directories | * building `mod_1.0.tar.gz' | | $ R CMD check mod | * using log directory '/home/simone/R/Rcpp/module/mod.Rcheck' | * using R version 2.13.1 (2011-07-08) | * using platform: x86_64-pc-linux-gnu (64-bit) | * using session charset: UTF-8 | * checking for file 'mod/DESCRIPTION' ... OK | * checking extension type ... Package | * this is package 'mod' version '1.0' | * checking package name space information ... OK | * checking package dependencies ... OK | * checking if this is a source package ... OK | * checking for executable files ... OK | * checking whether package 'mod' can be installed ... ERROR | Installation failed. | | The package skeleton was created with Rcpp.package.skeleton(). | | Here is the module directory structure: | $ /bin/ls -R mod | mod: | DESCRIPTION man NAMESPACE R Read-and-delete-me src | | mod/man: | mod-package.Rd | | mod/R: | zzz.R | | mod/src: | Makevars Makevars.win rcpp_module.cpp | | Here are the key files: | | $ cat mod/NAMESPACE | useDynLib(mod) | exportPattern("^[[:alpha:]]+") | import( Rcpp ) | | $ cat mod/R/zzz.R | | .onLoad<- function(libname, pkgname) { | require("methods", character=TRUE, quietly=FALSE) | loadRcppModules() | } | | $ cat mod/src/rcpp_module.cpp | #include<math.h> | #include<Rcpp.h> | | double norm( double x, double y ) { | return sqrt( x*x + y*y ); | } | | RCPP_MODULE(mod) { | using namespace Rcpp; | function( "norm",&norm ); | } | _______________________________________________ | 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
_______________________________________________ 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