Skip to content
Prev 6361 / 10988 Next

[Rcpp-devel] Multiple definition problem with RcppArmadillo:sample() function during package compilation

Le 2013-08-24 02:47, Dirk Eddelbuettel a ?crit?:
This is now fixed in svn.
The file did not have include guards and it was defining functions that 
were too long to be inlined.

Since I don't want the user to have to link against an RcppArmadillo 
library (like we do in Rcpp), I made these functions (SampleReplace, etc 
...) templates.
This should allow people to include this file more than once.

The alternative would be to only have declarations of the 
SampleReplace, etc ... functions in sample.h and definitions in a .cpp 
file in RcppArmadillo, but then we would need users to mess with their 
PKG_LIBS, and we would need to store a library we can link against. This 
is already a lot of trouble to do this with Rcpp, so I'm not doing that 
for RcppArmadillo.

The other alternative is to not host sample in RcppArmadillo but in 
another package. I don't have strong opinion on this, but sample is 
somewhat of an outlier in RcppArmadillo. RcppArmadillo is just supposed 
to make armadillo available. sample is an example use case.

Romain