[Rcpp-devel] Sharing Cpp code between packages

Gregor Kastner gregor.kastner at wu.ac.at
Tue May 20 17:34:33 CEST 2014

Hi Alessandro,

> 2. The "direct" mechanism: just put the code in inst/include and tweak
> the Makevars so that the compiler knows where to look for those
> headers. This should work also with structs and templated cpp code.
> I think I need the "direct" mechanism.
> In package P, I moved my hpp files in inst/include and tweaked the
> Makevars, the package compiled fine.
> Now in package Q I am trying to use some of the stuff, and I am
> including the files I need. I also did the following:
> 1. put import(P) in Q's namespace file
> 2. put Import P and LinkingTo P in Q's description file

I am not sure whether you can simply borrow a foreign package's header file
the way you intend to (but I'd be happy to learn how this works, even though
it seems a bit against the idea of exporting...).

Anyway, even though this doesn't really answer your question, it still might
be of some use. I am currently using Romain's suggestion to include other
functions, see here:



More information about the Rcpp-devel mailing list