Question

I am having a lot of trouble understanding the steps that construct the compilation flags when using R CMD SHLIB. I use the following:

  • in ~/.R/Makevars define `CPPFLAGS=-O3'
  • in src/Makevars.win define PKG_CPPFLAGS = -O3
  • include Rcpp and RcppGSL as dependencies in the DESCRIPTION file

where the second step is clearly redundant, but I do it just in case PKG_CXXFLAGS was initialized to something different.

But when I run R CMD SHLIB I find my -O3 flags but also -UNDEBUG -Wall -pedantic -g -O0. Where can those additional flags be coming from? Can Rcpp and RcppGSL affect these flags in a way I can't control through my Makevars.in?

Was it helpful?

Solution

For per-user, or personal settings, I just use ~/.R/Makevars which will affect all R CMD SHLIB or R CMD COMPILE calls, including those from Rcpp.

You can also define them in per-project Makefiles, or src/Makevars, and besides the per-user files, you can of course edit the system-wide variant (which is where the other values that confused you came from). See the file $R_HOME/etc/Makeconf for the latter.

Lastly, DESCRIPTION has nothing to do here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top