[Rcpp-devel] Rcpp.package.skeleton testmod

Dirk Eddelbuettel edd at debian.org
Mon Jun 3 19:57:53 CEST 2013


On 3 June 2013 at 19:31, Andreas Prescher wrote:
| Hello,
| 
| Any help would be greatly
| appreciated!!!!
| 
| I am trying to use the example
| testmod  package by using:
| 
| Rcpp.package.skeleton( "testmod", module = TRUE )
| and:
| R CMD INSTALL testmod
| 
| system information:
| R version 3.0.1 (2013-05-16)
| Platform: x86_64-pc-linux-gnu (64-bit),
| ubuntu 12.04 LTS
| /usr/local/lib/R/site-library/testmod/libs/testmod.so
| Rccp 0.10.3 (build from source with  as also RUnit, inline, rbenchmark)
| 
| What I've tried so far amongst other suggestions
| found on the web:
| 
| Test 1:
|  > require(Rcpp)
| Lade nötiges Paket: Rcpp
|  > yada <- Module( "yada", "testmod" )
|  > yada$hello()
| Fehler in Module(module, mustStart = TRUE) :
|    Failed to initialize module pointer: Error in 
| FUN("_rcpp_module_boot_yada"[[1L]], ...): no such symbol 
| _rcpp_module_boot_yada in package testmod
| 
| Test 2:
|  > require("testmod")
| Lade nötiges Paket: testmod
| Lade nötiges Paket: Rcpp
|  > yada$hello()
| Fehler: Objekt 'yada' nicht gefunden
| 
| Test 3:
|  > library(Rcpp)
|  > library(testmod)
|  > yada <- Module( "yada", "testmod" )
|  > yada$hello()
| 
|   *** caught segfault ***
| address 0xd8, cause 'memory not mapped'
| 
| Traceback:
|   1: .Call(symbol)
|   2: Module(module, mustStart = TRUE)
|   3: .getModulePointer(x)
|   4: yada$hello
| 
| Any help would be
| great, because I want to
| use my existing C++ classes
| in a R package and it
| would be great to have a starting
| point.

Creatiing, compiling, loading and using a modules package is part of R CMD
check.  I don't recall from the top of my head if the "yada" code is actually
part of the skeleton package -- you may have to copy that from the vignette.

The skeleton package tests this code (see the tests/ directory) and this
works.

R> setwd("/tmp/andreas/")
R> Rcpp.package.skeleton( "testmod", module = TRUE )
Creating directories ...
Creating DESCRIPTION ...
Creating NAMESPACE ...
Creating Read-and-delete-me ...
Saving functions and data ...
Making help files ...
Done.
Further steps are described in './testmod/Read-and-delete-me'.

Adding Rcpp settings
 >> added RcppModules: yada
 >> added Depends: Rcpp
 >> added LinkingTo: Rcpp
 >> added useDynLib directive to NAMESPACE
 >> added Makevars file with Rcpp settings
 >> added Makevars.win file with Rcpp settings
 >> added example header file using Rcpp classes
 >> added example src file using Rcpp classes
 >> added example R file calling the C++ example
 >> added Rd file for rcpp_hello_world
 >> copied the example module file 
R> library(testmod)
R> 
R> v <- new(vec)
R> data <- 1:10
R> v$assign(data)
R> v[[3]] <- v[[3]] + 1
R> data[[4]] <- data[[4]] +1
R> stopifnot(identical(all.equal(v$as.vector(), data), TRUE))
R> stopifnot(all.equal(bar(2), 4))
R> stopifnot(all.equal(foo(2,3), 6))
R> nn <- new(Num)
R> nn$x <- pi
R> stopifnot(all.equal(nn$x, pi))
R> 
R> v
C++ object <0x454a010> of class 'vec' <0x54c59b0>
R> nn
C++ object <0x446fed0> of class 'Num' <0x3a0cf30>
R> 

Dirk 


| 
| Best regards,
| 
| Andreas
| 
| 
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list