14 October 2012

Install RGL in Ubuntu

I had a few hurdles to get through when trying to install the “rgl” R package in Ubuntu. In summary, here was my solution:

From the terminal:

sudo apt-get install r-cran-dev xorg-dev libglu1-mesa-dev

Then from R:

install.packages("rgl")

Detailed Log

Thanks to Dirk Eddelbuettel for the following tip. He points out that, rather than all the guess-and-check below, he points out:

If you want to install from newer sources, ‘sudo apt-get build-dep r-cran-rgl’ will install all dependencies needed to builds the package saving you the guesswork.

I’ll be sure to do that next time! For posterity’s sake, here was the detailed log of my first attempt.

The first snag I hit was the following implying I was missing some necessary X code:

checking for X... no
configure: error: X11 not found but required, configure aborted.
ERROR: configuration failed for package ‘rgl’

You’ll need the xorg-dev package to get around this issue. I then hit an error regarding a GL library:

checking for X... libraries , headers
checking GL/gl.h usability... no
checking GL/gl.h presence... no
checking for GL/gl.h... no
checking GL/glu.h usability... no
checking GL/glu.h presence... no
checking for GL/glu.h... no
configure: error: missing required header GL/gl.h
ERROR: configuration failed for package ‘rgl’

A quick Google showed that the libglu1-mesa-dev package contained these headers. Once I had installed those package, the install process went smoothly!

Note, too, that there may be a precompiled package may be available for your distribution under the name r-cran-rgl. In my case, I needed a more recent version of the package than was offered there, hence this exploration.