Reputation: 33
I am using Rcpp to write an R package, which also uses some C++ code, but each time I do R CMD build <package name>
, it needs a really long time to compile the whole packages, since there are couple of cpp files. Is there a way I can only compile the changed files/new files, instead of recompiling everything? Thank you very much!
I have a Makevars file like this:
PKG_CXXFLAGS=-std=gnu++11
PKG_LIBS=-L. -lall
Upvotes: 3
Views: 632
Reputation: 368231
The best trick I know is to deploy the awesome frontend ccache which most Linux distros have, and which OS X has too (in Brew IIRC). It can be used with both g++
and clang
.
So in ~/.R/Makevars
I have
VER=
CCACHE=ccache
CC=$(CCACHE) gcc$(VER)
CXX=$(CCACHE) g++$(VER)
SHLIB_CXXLD=g++$(VER)
FC=ccache gfortran$(VER)
#FC=gfortran
F77=$(CCACHE) gfortran$(VER)
where VER
is currently empty as 4.9 is the default. Now if you re-build the same package over and over, the compile-time is very fast as unchanged code leads to object files being retrieved.
Upvotes: 10