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

Dirk Eddelbuettel edd at debian.org
Sat Aug 24 19:32:26 CEST 2013


On 24 August 2013 at 09:04, romain at r-enthusiasts.com wrote:
| 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.

Thanks!
 
| 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.

Nobody suggested that. RcppArmadillo is, and should remain for the forseeable
future, a templates-based headers-only library.
 
| 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.

Which is why it is off to the side and not included by default. I think that
is a reasonably setup.

A package of its own is possibly, but a tad on the heavy side for a single
header file of a few dozen lines.  Other suggestions are surely welcome.

Dirk

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


More information about the Rcpp-devel mailing list