Installing RLink on Linux

I have R installed separately and can do :

InstallR["RHomeLocation" -> "/usr/lib64/R"]

I am able to run the examples provided in the documentation. I use Fedora 17 64 bit.


I also had this problem on Ubuntu 12.04, but this solution didn't help me. I think I've gotten it solved though. I suspect that several of my steps were unnecessary (or unnecessarily convoluted) but here goes:

First, make the R launch script and binary installed by Mathematica executable. I don't know if Mathematica actually runs these, but it did allow me to test them.

 cd ~/.Mathematica/Paclets/Repository/RLinkRuntime-Linux-x86-64-9.0.0.0/SystemFiles/Linux-x86-64/R/bin
 chmod +x R
 cd exec
 chmod +x R
 cd ..
 gedit R

or whatever text editor. The launcher script had lots of references to "/Developer/leonids/" hardcoded into paths. I replaced the following lines:

04 R_HOME_DIR=/home/{my username}/.Mathematica/Paclets/Repository/RLinkRuntime-Linux-x86-64-9.0.0.0/SystemFiles/Linux-x86-64/R
35 R_SHARE_DIR="${R_HOME_DIR}/share"
37 R_INCLUDE_DIR="${R_HOME_DIR}/include"
39 R_DOC_DIR="${R_HOME_DIR}/doc"

After this, R still didn't work from the command line; it complained about not having libg2c.so.0. That's not available in any currently maintained Ubuntu distro, but I tracked down an RPM: compat-libf2c-34-3.4.6-9.x86_64.rpm. So,

sudo alien compat-libf2c-34-3.4.6-9.x86_64.rpm
sudo dpkg -i compat-libf2c-34-3.4.6-9.x86_64.deb

R continued to complain about missing libg2c.so.0. It turns out it was in the wrong place, because 64 bit Fedora and Ubuntu keep their libraries in different places.

sudo cp /usr/lib64/libg2c.* /usr/lib/

Voilà! R now works from the command line, and RLink works as well.

Incidentally, it looks like libg2c is basically deprecated now, so ideally, it would be removed as a dependency in favor of a more modern FORTRAN runtime, e.g. gfortran.


What I suspect is happening is that your flavor of Linux either lacks certain libraries which we considered standard, or has versions of those libraries which are in conflict with some of the ones we ship with the internal R distribution. Unfortunately, it is not easy to diagnose exactly which libraries are problematic, but I will try to follow up on this.

The situation with Linux is currently as follows: we tried our best to test on various Linux distributions, but the way RLink's default R distribution works is such that on some Linux distros there might be library version conflicts, since we had to augment the R distro with additional dependent libraries.

We did test on CentOS 5, and also on Ubuntu. I just re-tested and RLink works for me on Ubuntu 10.04 32 bit running on the virtual box (VMWare). And, it is almost certainly not Java, since RLink uses the JVM that comes with Mathematica. What we will do for Linux is to collect various problems like that, and try to resolve them to the best we can. However, some problems are inherent to Linux having many different flavors with somewhat different core libraries.