[Rcpp-devel] inline plug-in linking

JJ Allaire jj.allaire at gmail.com
Fri Nov 16 17:50:18 CET 2012

> Anyhow, I think I am probably missing some linking info from my
> inlinePlugIn statement.

This is the key -- plugins that do linking are much more complicated than
ones that rely on headers only. You can look at the Rcpp and RcppGSL
packages as examples -- in short there needs to be a function inside the
package that can cough up the correct library locations. If you get this
far then your stuff will work with inline and Rcpp::cppFunction, however
people developing packages that want to link against your stuff will need
custom Makevars entries (which you can configure the inline plugin to
produce, but by now things have gotten pretty complicated for your users).

If you can manage to do header-only "linking" that will be much, much
simpler. At the lowest level the key to this is R_GetCCallable. In Rcpp
land there is a GetCppCallable equivalent that works with modules. You can
see the use of this in the header file which is generated by
Rcpp::interfaces(r, cpp).

If you want to expose the data structure using this mechanism then you
could write a function like this:

// [[Rcpp::export]]
Rcpp::List getModelStatistics() {
   return StatController::getModelStatistics();

And then compileAttributes will automatically generate the shim that calls
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20121116/338fa1de/attachment.html>

More information about the Rcpp-devel mailing list