[Rcpp-devel] Use of "Depends: Rcpp" in packages using Rcpp
cubranic at stat.ubc.ca
Tue Jan 7 09:18:48 CET 2014
On Jan 6, 2014, at 5:45 PM, French, Joshua <JOSHUA.FRENCH at UCDENVER.EDU> wrote:
> I¹m not sure if this question is in reference to an email from Brian
> Ripley, but I was under the impression that we should include Rcpp and/or
> RcppArmadillo in Depends so that it is not installed for binary versions
> of the packages.
It was prompted by that email, yes, but then I started to wonder why have Rcpp in the “Depends” in the first place. The code I’m fixing was written before I had a good understanding of packages and namespaces, and nowadays I think twice before I add something to “Depends” (as opposed to keeping it in “Imports”).
But I think you missed Ripley’s point: having a package in “Depends” will install it even for binary versions of dependents, which is unnecessary for a headers-only package like RcppArmadillo. The way to avoid it is to have it appear *only* in “LinkingTo”.
Note that this only applies to RcppArmadillo — Rcpp is not a headers-only package. As such, I *thought* I had to have it installed even for binary versions of the dependents, in order for them to link to its DLL. But after some experimentation with my package, that appears not to be the case. FWIW, I was able to have both Rcpp and RcppArmadillo only in LinkingTo, and the binary version of my package can now be installed (and pass a reasonably complete test suite) even on computers where Rcpp and RcppArmadillo are not present.
At first, I thought that maybe in my package I really only use the headers — it’s an old package and I’m not using any “newish” features such as modules. I then realized that Rcpp:::LdFlags is statically linking to “libRcpp.a”, so no DLLs are required at runtime. This is on a Mac, and so I don’t think it will work on Linux, where Rcpp is built as a dynamic library, at least with the current CRAN version (0.10.6). But then I saw on Github that the whole business of building (and linking to) an Rcpp library is being deprecated. Maybe Romain can comment on this. Rcpp-package vignette hasn’t been updated there.
More information about the Rcpp-devel