[Rcpp-devel] Hello world for Rcpp modules
Dirk Eddelbuettel
edd at debian.org
Fri Aug 12 16:56:15 CEST 2011
On 12 August 2011 at 07:34, Chris DuBois wrote:
| 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.
Well then maybe do some cleanup at your end. As I said, it works in all
regression tests and explicitly too, so I still think this is local to your
end. See here:
edd at max:~$ cd /tmp/
edd at max:/tmp$ r -lRcpp -e'Rcpp.package.skeleton("chrisExample",module=TRUE)'
Attaching package: 'utils'
The following object(s) are masked from 'package:Rcpp':
.DollarNames, prompt
Creating directories ...
Creating DESCRIPTION ...
Creating NAMESPACE ...
Creating Read-and-delete-me ...
Saving functions and data ...
Making help files ...
Done.
Further steps are described in './chrisExample/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
edd at max:/tmp$ R CMD INSTALL chrisExample/
* installing to library ‘/usr/local/lib/R/site-library’
* installing *source* package ‘chrisExample’ ...
** libs
ccache g++-4.5 -I/usr/share/R/include -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g0 -O3 -Wall -pipe -pedantic -Wno-variadic-macros -c rcpp_hello_world.cpp -o rcpp_hello_world.o
ccache g++-4.5 -I/usr/share/R/include -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g0 -O3 -Wall -pipe -pedantic -Wno-variadic-macros -c rcpp_module.cpp -o rcpp_module.o
g++ -shared -o chrisExample.so rcpp_hello_world.o rcpp_module.o -L/usr/local/lib/R/site-library/Rcpp/lib -lRcpp -Wl,-rpath,/usr/local/lib/R/site-library/Rcpp/lib -L/usr/lib64/R/lib -lR
installing to /usr/local/lib/R/site-library/chrisExample/libs
** R
** preparing package for lazy loading
** help
Warning: /tmp/chrisExample/man/chrisExample-package.Rd:32: All text must be in a section
Warning: /tmp/chrisExample/man/chrisExample-package.Rd:33: All text must be in a section
*** installing help indices
** building package indices ...
** testing if installed package can be loaded
* DONE (chrisExample)
edd at max:/tmp$ r -lchrisExample -p -e'rcpp_hello_world()'
[1] "chrisExample" "Rcpp" "methods" "base"
[[1]]
[1] "foo" "bar"
[[2]]
[1] 0 1
edd at max:/tmp$
r is from littler, -lfoo loads package foo, -p enables print and -e evaluates
the expression.
The 'ccache g++-4.5' comes from my ~/.R/Makevars.
Dirk
--
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
More information about the Rcpp-devel
mailing list