Building R Packages using Alternate GCC

This is not that well documented (e.g. I failed to locate it in either ‘R Extension’ or ‘R Admin’ right now) but Brian Ripley mentioned it a few times on the lists.

Basically, at R compile time, settings are registered and the stored in $R_HOME/etc/Makeconf. One possibility is to edit that file directly, but you may not have root privileges or may not want to affect all other users. So the better may be to create

~/.R/Makevars

with entries

CC=gcc-4.4
CXX=g++-4.4

plus whichever optmisation flags etc you want to set. That will the affect all subsequent uses of R CMD INSTALL or R CMD check or … that you run.

Other files in $R_HOME/etc/ can similarly be overridden locally from ~/.R/.

Leave a Comment