[Rcpp-devel] Hello world for Rcpp modules

Chris DuBois chris.dubois at gmail.com
Fri Aug 12 16:34:03 CEST 2011


Sorry, but that's just me being lazy with my lib directory.  When I start R
back up in my example, you'll see it's 2.13.1.

On Fri, Aug 12, 2011 at 6:07 AM, Dirk Eddelbuettel <edd at debian.org> wrote:

>
> Hi Chris,
>
> On 11 August 2011 at 22:23, Chris DuBois wrote:
> | 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’
>
> Rcpp has dependended on R (>= 2.12) for quite some time, and Module
> definitely requires it.
>
> How did you get Rcpp installed on that version of R, and what version of
> Rcpp
> is it?
>
> Something like the example you show here is part of the unit tests and
> clearly works with current R and Rcpp versions.  Can you get hold of a
> newer
> R somewhere to try it?
>
> Dirk
>
> | * 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
> |
> |
> | ----------------------------------------------------------------------
> | _______________________________________________
> | 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
>
> --
> Two new Rcpp master classes for R and C++ integration scheduled for
> New York (Sep 24) and San Francisco (Oct 8), more details are at
>
> http://dirk.eddelbuettel.com/blog/2011/08/04#rcpp_classes_2011-09_and_2011-10
>
> http://www.revolutionanalytics.com/products/training/public/rcpp-master-class.php
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110812/be3fa147/attachment.htm>


More information about the Rcpp-devel mailing list