[Rcpp-devel] calling a homegrown cpp function from my own package when using sourceCpp

Dirk Eddelbuettel edd at debian.org
Mon Dec 30 03:12:43 CET 2013

Hi Søren,

On 30 December 2013 at 01:59, Søren Højsgaard wrote:
| I have created a function c++ function foo which I export with //[[Rcpp::export]]. I've put the file foo.cpp with the function into the src dir of the package mypack; I've run compileAttributes and I can see the function in mypack_RcppExport.h and the automatically generated interface to the function is available in R (these Rcpp-attributes really make life easier).
| Now I want to develop another function bar in the file bar.cpp and bar depends on foo. I want to develop bar using sourceCpp("bar.cpp") but I can not figure out how to make my c++ function foo available to bar. In bar.cpp I have 
| //[[Rcpp::depends(mypack)]] but that does not make foo available.
| Is it possible to do what I want (I believe it is from the documentation?) or is there another "workaround"??

I think Section 3.5 in the vignette 'Rcpp Attributes' is what you want here.

Happy New Year to you too!


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

More information about the Rcpp-devel mailing list