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/.


Check your path to see if /usr/local/bin comes before /usr/bin. If it does, just make sure /usr/bin comes first:

PATH=/usr/bin:${PATH}

(it's okay if /usr/bin is duplicated appears twice).


I had a very similar problem.

What worked for me was to define a project directory (rstudio can do that for you), and then add a .Renviron file that modifies the PATH and LD_LIBRARY_PATH, to include the directory with the new gcc. In your case, for example, the .Renviron will look something like:

LD_LIBRARY_PATH=/usr/local/bin/gcc/lib:/usr/local/bin/gcc/lib64:/usr/local/bin/gcc/libexec:other paths

PATH=/usr/local/bin/gcc/bin:/usr/local/bin:other paths

Tags:

Bash

Gcc

R