tags:

views:

104

answers:

2

The systems I work with have GCC 4.5 (experimental) in /usr/local/bin/gcc which has proven to be problematic for some R packages. I would like to instead use system GCC in /usr/bin/gcc.

I have tried setting CC and CXX in the Bash configuration files (.bashrc, .bash_profile etc.) as well as on the command line, but although Bash recognizes the change, R does not.

How can I get R to use the version of GCC in /usr/bin instead of the one in /usr/local/bin/?

A: 

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

R Samuel Klatchko
Didn't work:export PATH=/usr/bin:${PATH}R CMD INSTALL...checking for gcc... /usr/local/bin/gcc -std=gnu99
Ryan Rosario
+3  A: 

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 $RHOME/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 $RHOME/etc/ can similarly be overridden locally from ~/.R/.

Dirk Eddelbuettel
With my configuration, certain packages require sudo, so in those cases it is necessary to modify Makeconf. Your solution works!
Ryan Rosario