[Rcpp-devel] correct way of making custom as and wrap functions available to other packages

Simon Barthelmé simon.barthelme at gipsa-lab.fr
Fri Jul 17 16:32:40 CEST 2015

Dear list,

For a package I'm developing (https://github.com/dahtah/imager/) I had 
to write custom "as" and "wrap" functions for third-party classes. I'd 
like to make these wrappers accessible to other developers via inline 
C++ as well as LinkingTo directives (so that they can be used in other 
So far I've only managed the former: I have a header file in 
inst/include, called "wrappers.h", that contains the full 
implementations of my custom as and wrap functions. I've written a 
custom inline plugin and everything works fine. However, LinkingTo 
doesn't work: wrappers.h gets included in multiple object files and I 
get linking errors (the linker complains about multiple declarations of 
"as" and "wrap").
I understand RcppArmadillo manages to get around the problem but I can't 
figure out how. What's the correct way of doing this? Is there a way of 
making as and wrap inline functions so that it's safe to have 
header-only implementations?


Simon Barthelme

More information about the Rcpp-devel mailing list