In the past, I’ve described how one could build multiarch (64 bit and 32 bit) versions of R on a 64 bit Ubuntu machine. The method based on this thread no longer works as of R 2.13 or 2.14 I believe. I received advice from someone on #R
over on freenode
(forgot who) a few months ago that suggested the chroot route (see this also). I recently tried it and wanted to document the procedures. Although the solution isn’t as nice as the previous multiarch route, it will suffice for now. With the chroot
method, first compile the 64 bit version of R the usual way. For the 32 bit version of R, do:
<pre class="src src-sh"><span style="color: #ff4500;">#### </span><span style="color: #ff4500;">change my.username to your username, or modify path per your taste</span>
### create chroot jail sudo apt-get install dchroot debootstrap sudo mkdir ~/chroot-R32 sudo emacs -q -nw /etc/schroot/schroot.conf ## paste the following in the file: (no quotes) “ [natty] description=Ubuntu Natty location=/home/my.username/chroot-R32 priority=3 users=my.username groups=sbuild root-groups=root “
## build a basic Ubuntu system in the chroot jail sudo debootstrap –variant=buildd –arch i386 natty /home/my.username/chroot-R32 http://ubuntu.cs.utah.edu/ubuntu/ ## pick a mirror from https://launchpad.net/ubuntu/+archivemirrors
## copy my source locations for apt sudo cp /etc/apt/sources.list /var/chroot/etc/apt/sources.list ## edit this new file if to reflect only the needed source
### do following steps whenever you need to access 32 bit R ## access to proc and dns sudo mount -o bind /proc /home/my.username/chroot-R32/proc sudo cp /etc/resolv.conf /home/my.username/chroot-R32/etc/resolv.conf ## go into jail; do this whenever you want sudo chroot /home/my.username/chroot-R32 dpkg-architecture ## make sure system is i386 ### now the root / location should reflect the jail
### following happens in jail ## tools needed to build R apt-get install gcc g++ gfortran libreadline-dev libx11-dev xorg-dev ## get svn to get latest r source code apt-get install git-core subversion
## compile 32 bit R cd home/ mkdir R32 cd R32 svn checkout https://svn.r-project.org/R/trunk/ r-devel cd r-devel/ apt-get install rsync ./tools/rsync-recommended ./configure make make install R
How big is my /home/my.username/chroot-R32
folder? It is at 791 MB after the above steps. Let me know if you have suggestions for having both 32 bit or 64 concurrently on Linux. I believe Windows and Mac ships and compiles both 32 bit and 64 bit versions of R. I’m surprised this isn’t the case for Linux.
Why would you want 32 bit R on a 64 bit machine?
Yes, seems weird, but I have a package that only works in 32 bit and not 64 bit. Don’t know how to fix the C code to make it work with 64 bit yet.
Very useful. How can you launch it using R arch=i386 or something similar ? You have to always chmod ?
You can do so previously by compiling both archs (see first link in the post). However, I’m unable to do this for recent versions of R, hence the chroot method.
I was unable to install the 32-bit version of R with chroot.
The following command line displays the error:
sudo debootstrap – variant = buildd – arch i386 natty / home/my.username/chroot-R32 http://ubuntu.cs.utah.edu/ubuntu/ # # pick a mirror from https://launchpad.net/ ubuntu / + archivemirrors
E: Failed getting release file http://ubuntu.cs.utah.edu/ubuntu/dists/natty/Release
Is there any other way to install 32-bit R in 64-bit ubuntu without using chroot?