I have a R package for which I moved an MCMC algorithm containing matrix algebra to C++
using the RcppEigen
package which dramatically improved the speed.
However, R CMD check
gives the following NOTE
on Linux (Thanks to R-Forge):
* checking installed package size ... NOTE
installed size is 6.6Mb
sub-directories of 1Mb or more:
libs 6.1Mb
This warning is probably not driven by the incredible size of my C++ code (which is only around 150 lines), as it only appears on Linux, but probably by my inability to correctly configure the Makevars
file. (I have never used make
or a makefile
before).
Also when submitting the package to CRAN
, Brian Ripley wrote something regarding this NOTE
that makes me expect it is a Makevars
problem: "It comes from debugging symbols."
My Makevars
are the standard Rcpp
Makevars
(given below) produced by Rcpp.package.skeleton
.
My questions:
Makevars
in a way that reduces the size of the compiled library on Linux (i.e., get rid of the NOTE
)?Makevars
for Rcpp
?my Makevars
:
## Use the R_HOME indirection to support installations of multiple R version
PKG_LIBS = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"`
PKG_CPPFLAGS = -I. -I../inst/include
my Makevars.win
:
## This assume that we can call Rscript to ask Rcpp about its locations
## Use the R_HOME indirection to support installations of multiple R version
PKG_LIBS = $(shell $(R_HOME)/bin/Rscript.exe -e "Rcpp:::LdFlags()")
PKG_CPPFLAGS = -I. -I../inst/include
You quote what we wrote. There is nothing specific here: you just want to learn about basic Makefile syntax and options.
Fiddling with src/Makevars
, unless you understand what you are doing, is not recommended. You will likely break something, particularly builds on another architecture. Simon Urbanek is pretty adamant about this advice.
Brian Ripley is of course half-correct: If you have debugging enabled, libraries are larger. But CXXFLAGS
are never set, particularly no -g
flag is set to turn debugging on. So it is not us: if debugging is enabled by default, something else turned it on. Could be R by default. See your .R/Makevars
.
The other driver for size is C++ templates. Compare with other packages using (Rcpp)Eigen, they are likely large too. This "is just a cost of doing business": the templates give you the (coding) power you enjoy.
Edited for typos
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With