[Rcpp-devel] Hello world for Rcpp modules

Chris DuBois chris.dubois at gmail.com
Fri Aug 12 07:23:40 CEST 2011


Hi all,

I've created a package using Rcpp.package.skeleton("pkg",module=TRUE).

If I create a file R/hello_world2.R with the following

show(World)
b <- new(World)
b$greet()
b$set("hello everybody")
b$greet()
rm(b)

then I receive an "execution halted" error when I try to compile the package
using R CMD INSTALL pkg.  Why is this?

I've included my steps below.

> library(Rcpp)  # latest version from CRAN
> Rcpp.package.skeleton("pkg",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 './pkg/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
> q()
Save workspace image? [y/n/c]: n
chris at seldon:~/Documents/networkstats$ R CMD INSTALL pkg
* installing to library ‘/home/chris/R/i486-pc-linux-gnu-library/2.10’
* installing *source* package ‘pkg’ ...
** libs
g++ -I/usr/share/R/include
-I"/home/chris/R/i486-pc-linux-gnu-library/2.10/Rcpp/include"   -fpic  -O3
-pipe  -g -c rcpp_hello_world.cpp -o rcpp_hello_world.o
g++ -I/usr/share/R/include
-I"/home/chris/R/i486-pc-linux-gnu-library/2.10/Rcpp/include"   -fpic  -O3
-pipe  -g -c rcpp_module.cpp -o rcpp_module.o
g++ -shared -o pkg.so rcpp_hello_world.o rcpp_module.o
-L/home/chris/R/i486-pc-linux-gnu-library/2.10/Rcpp/lib -lRcpp
-Wl,-rpath,/home/chris/R/i486-pc-linux-gnu-library/2.10/Rcpp/lib
-L/usr/lib/R/lib -lR
installing to /home/chris/R/i486-pc-linux-gnu-library/2.10/pkg/libs
** R
** preparing package for lazy loading
** help
Warning: /home/chris/Documents/networkstats/pkg/man/pkg-package.Rd:32: All
text must be in a section
Warning: /home/chris/Documents/networkstats/pkg/man/pkg-package.Rd:33: All
text must be in a section
*** installing help indices
** building package indices ...
** testing if installed package can be loaded

* DONE (pkg)
chris at seldon:~/Documents/networkstats$ R
R version 2.13.1 (2011-07-08)
> library(pkg)
Loading required package: Rcpp
> source("pkg/R/rcpp_hello_world.R")
> rcpp_hello_world()  # works as expected
[[1]]
[1] "foo" "bar"

[[2]]
[1] 0 1
> q()
chris at seldon:~/Documents/networkstats$ cp rcpp_hello_world2.R pkg/R/
chris at seldon:~/Documents/networkstats$ R CMD INSTALL pkg
* installing to library ‘/home/chris/R/i486-pc-linux-gnu-library/2.10’
* installing *source* package ‘pkg’ ...
** libs
make: Nothing to be done for `all'.
installing to /home/chris/R/i486-pc-linux-gnu-library/2.10/pkg/libs
** R
** preparing package for lazy loading
Execution halted
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110811/e897949a/attachment.htm>


More information about the Rcpp-devel mailing list