[Rcpp-devel] Plugin example
Wagner Bonat
wbonat at gmail.com
Mon Jun 1 19:06:59 CEST 2015
Dear all,
I am starting to study the Rcpp package. I am reading the Rcpp book, butI
have a problem on Listing 2.8 from Rcpp book. This listing is about
Creating Plugins.
## The C++ code
gslrng <-'
int seed = Rcpp::as<int>(par) ;
gsl_rng_env_setup();
gsl_rng *r = gsl_rng_alloc (gsl_rng_default);
gsl_rng_set (r, (unsigned long) seed);
double v = gsl_rng_get (r);
gsl_rng_free(r);
return Rcpp::wrap(v);
'
## Creating the plugin
plug <- Rcpp:::Rcpp.plugin.maker(
include.before = "#include <gsl/gsl_rng.h>",
libs = paste("-L/usr/local/lib/R/site-library/Rcpp/lib -lRcpp",
"-Wl,-rpath,/usr/local/lib/R/site-library/Rcpp/lib",
"-L/usr/lib -lgsl -lgslcblas -lm"))
## Run
registerPlugin("gslDemo", plug)
fun <- cxxfunction(signature(par="numeric"), gslrng, plugin ="gslDemo",
verbose=TRUE)
When I try compile I received this error message
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! /usr/bin/ld: cannot
find -lRcpp
collect2: error: ld returned 1 exit status
make: *** [file1a3c6aca3e2e.so] Error 1
Any help is welcome.
Thank you!
--
Wagner Hugo Bonat
----------------------------------------------------------------------------------------------
Department of Mathematics and Computer Science (IMADA)
University of Southern Denmark (SDU) and
Laboratório de Estatística e Geoinformação (LEG)
Universidade Federal do Paraná (UFPR)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20150601/e3d7572d/attachment.html>
More information about the Rcpp-devel
mailing list