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

August 11, 2011

(This article was first published on Super Nerdy Cool » R, and kindly contributed to R-bloggers)

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:

## download R source from tar ball or svn
## working directory has R/trunk/
## run in trunk
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:

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

To leave a comment for the author, please follow the link and comment on their blog: Super Nerdy Cool » R. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.


Mango solutions

RStudio homepage

Zero Inflated Models and Generalized Linear Mixed Models with R

Dommino data lab

Quantide: statistical consulting and training



CRC R books series

Six Sigma Online Training

Contact us if you wish to help support R-bloggers, and place your banner here.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)