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.

R from source

The following are notes for myself.

I like to use the bleeding edge version of R:

<pre class="example">svn checkout r-devel

cd r-devel ./tools/rsync-recommended

use the following to update sources: svn update


sudo apt-get build-dep r-base

sudo apt-get install gcc g++ gfortran libreadline-dev libx11-dev xorg-dev

sudo apt-get install texlive texinfo

./configure make sudo make install

Amazon EC2 free hosting (micro instance) for 1 year – Ubuntu + WordPress + Asterisk

I use old laptops as web servers at school. However, they really aren’t built to be running continuously; I have disk problems on both of my old laptops. Amazon Web Services offer a free usage tier of EC2 cloud service for 1 year. After the 1 year, the micro instance cost about $.02/hr, which is still pretty cheap. I sign up for an account with Amazon Elastic Compute Cloud (EC2), started an instance, installed the ami-3e02f257 AMI, downloaded the private key, and the ball started to roll. Before you can ssh to your server, you have to set up the firewall from the management console of EC2 to open port 22 per this post. To log in and set up, I had to download the private key (PEM) that amazon generated and logged in as the user ubuntu (root is not allowed for my chosen AMI; this is the default user per the AMI):

<pre class="src src-sh">ssh -i /path/to/amazon.pem ubuntu@permanent.dns

Once logged in, I changed the ssh configuration to allow user logins. Then, I created my user account:

<pre class="src src-sh"><span style="color: #ff4500;">## </span><span style="color: #ff4500;"></span>

sudo useradd -d /home/username -m username ## create user sudo passwd username ## set password

## sudo adduser username admin

## sudo emacs -q -nw /etc/passwd ## change /bin/sh to /bin/bash

Now I can log in with my username, and enable passwordless ssh.

Now that Ubuntu is set up, I can install everything I want subject to the constraints of the server. Let’s see how this goes…

Latest Asterisk on Ubuntu

I recently changed my web server, and had to re-install Asterisk. I wanted to compile from source but I had an “input/output” error, which means either my drive is bad or I’m having issues with the kernel. SMART tells me my drive is OK, so I assume it’s the kernel.

I found this that has fairly recent versions of asterisk available.

Based on my setup, I also had issues with playing wav files when ran with the default daemon (user and group is asterisk). Resorted to the daemon I did before when I compiled from source.

Automatically start Asterisk at boot time

Learned how to do so from this thread.

 <pre class="src src-sh"><span style="color: #b0c4de;">cd</span> ~/Downloads/asterisk/1.8/contrib/init.d <span style="color: #ff4500;">## </span><span style="color: #ff4500;">contrib folder is in source directory</span>

sudo cp rc.debian.asterisk /etc/init.d/asterisk sudo chmod 755 /etc/init.d/asterisk # to set the script as boot update-rc.d asterisk defaults

# to remove the script from boot update-rc.d -f asterisk remove

Modify the /etc/init.d/asterisk:

<pre class="src src-sh"><span style="color: #ff4500;"># </span><span style="color: #ff4500;">Full path to asterisk binary</span>


Future of computing?

This is what I envision the future of computing to be if things were up to me. I can turn on any computer and be able to access an environment that has all the applications I use via a web login. That is, I should be able to remotely log in to my computer/server from any computer that has a web browser and be able to do things on it very fast. I also envision computers to be portable like that of an ipad, but with a keyboard peripheral that can connect to the device to turn it into a laptop (can’t live without keyboard shortcuts; think emacs and conkeror).

The cloud computing piece is partially addressed by eyeOS. However, I have not yet tried it since it isn’t Debian-based (hence not “mainstream”) and appears to have to be installed on top of a another OS (eg, via VirtualBox). I would want the remote login from the web to be a built in feature of Debian.

The portability piece I’m sure will be widely available soon due to all the tablet manufacturing going on. I’ve actually seen one with a portable keyboard attached to turn the tablet into a laptop prior to the ipad release, but have forgotten the link.

I wonder if my dream will come true.

flags for compiling source code: pkg-config command

so i was trying to compile some C code on my server at school that involves the math and the GNU Scientific Library (gsl) libraries. that is, the source has the following lines:

 <pre class="src src-C"><span style="color: #b0c4de;">#include</span> <span style="color: #ffa07a;">&lt;stdio.h&gt;</span>

#include <math.h> #include <gsl/gsl_integration.h>

those link the header files. however, when compiling, gcc would complain that they can’t see functions such as sqrt, abs, etc, from the math library. it also complains about my call to a function from the gsl library. i googled the math library stuff and realized i need to pass the ‘-lm’ argument in gcc for the math library. similarly, i saw somewhere that refers to the ‘-gsl’ argument. however, this did not work for me. i tried many things. some more googling, i found this thread that shows the ‘pkg-config’ command that shows exactly what arguments u need for which library.

So, i get:

 <pre class="src src-sh">$ pkg-config --libs gsl

-lgsl -lgslcblas -lm

so i just need to execute:

 <pre class="src src-sh">gcc -lgsl -lgslcblas -lm myprogram.c

i really don’t understand how the GNU compilers work. on my mac, i don’t have to pass those arguments. on my debian server, i need to. at first i thought that including the header was enough. will need to learn more about this stuff.

PS I also remember using this command when i had a hard time compiling shell-fm on my mac os x.

UPDATE: so on my mac os x, after installing gsl, i need to use ‘gcc -lgsl myprog.c’ to use the gsl library. things are fine now. I also want to note that i could not compile GSL form source on my debian server…had to rely on apt-get.

stumpwm on mac os x

stumpwm is to window managing (tiling?) system what emacs is to text editing and conkeror is to web browsing.

very cool. if i was on a linux laptop/desktop like i used to be, i would definitely use this. i’m even debating on quitting my mac os x for this (with emacs and conkeror). however, i most likely won’t since mac os x is pretty stable and most new stuff will be compatible with it (ease of use, plug and play).

i wanted to get stumpwm working on mac os x (intel based) like this post, but i never got it to work. somehow, i got it to work. my steps:

  1. update xquartz like the post said.
  2. install sbcl via macports.

UPDATE: actually, i think i used the sbcl for mac via this site.

  1. download the stumpwm source:

git clone git://

  1. followed the README file of stumpwm for sbcl:
  <pre class="src src-sh">$ sbcl

* (require ‘asdf) * (require ‘asdf-install) * (asdf-install:install ‘clx) * (asdf-install:install ‘cl-ppcre)

this step gave me MANY errors. i kept selecting the option to retry and continue like crazy. i finally gave up.

  1. continued with README
  <pre class="src src-sh">autoconf <span style="color: #ff4500;">##</span><span style="color: #ff4500;">get if not available. macports?</span>

./configure ##may need to specify sbcl if clisp is also installed make

stumpwm binary should be installed

  1. put following in ~/.xinitrc:

exec ~/Downloads/stumpwm/stumpwm ## path to stumpwm binary

launch programs in X (for example, xterm). look at stumpwm manual for keyboard shortcuts. very cool. this makes me REALLY want to go back to linux as my main computer.