Build multiarch R (32 bit and 64 bit) on Debian/Ubuntu

I have the 64 bit version of R compiled from source on my Ubuntu laptop. I recently had a need for R based on 32 bit since a package I needed to compile and use only works in 32 bit. I thought it was readily available on Ubuntu since both 32 bit and 64 bit versions of R are shipped with the Windows and Mac OS X installers. I tried figuring out how to do so using the manual (R 2.13.1), but could not figure it out on my own. I seeked help on R-devel and received some helpful responses.

Here is a quick reminder for myself:

<pre class="src src-sh"><span style="color: #ff4500;">## </span><span style="color: #ff4500;">download R source from tar ball or svn</span>

## working directory has R/trunk/ ## run in trunk ./tools/rsync-recommended sudo apt-get install ia32-libs lib32readline6-dev lib32ncurses5-dev lib32icu-dev gcc-multilib gfortran-multilib ## ubuntu does not have ia32-libs-dev # cd ../.. # mkdir R32 # cd R32 # ../R/trunk/configure r_arch=i386 CC=’gcc -std=gnu99 -m32′ CXX=’g++ -m32′ FC=’gfortran -m32′ F77=’gfortran -m32′ # make -j24 && sudo make install # cd .. # mkdir R64 # ../R/trunk/configure r_arch=amd64 # make -j24 && sudo make install ./configure r_arch=i386 CC=‘gcc -std=gnu99 -m32′ CXX=‘g++ -m32′ FC=‘gfortran -m32′ F77=‘gfortran -m32′ make -j24 && sudo make install make clean ./configure r_arch=amd64 make -j24 && sudo make install

You can build directly in the R/trunk, but make sure you execute make clean first to clear out any previous builds. Not doing so gave me errors like:

 <pre class="src src-sh">/usr/bin/install: cannot create regular file

`../../include/i386/Rconfig.h': No such file or directory

Now, executing R will give me the 64 bit version of R (whatever was the last build). If I want to specify the arch, I can just issue the commands R --arch i386 or R --arch amd64. When launching R in emacs, do C-u M-x R and type in the --arch argument.

Do a make uninstall to remove R prior to installing a new version of R to the same location.

About Vinh Nguyen

Statistician

1 comment

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>