Monday, September 22, 2008

Installing Ruby's linalg in Ubuntu

Ruby has a project for download called linalg that exposes the LAPACK functions in Ruby. LAPACK is a set of routines written in Fortran to do Linear Algebra operations. Now, before you cry foul about Fortran, LAPACK is used in a lot of places, and it's pretty damn old and has held up over the years.

The linalg package just updated about two weeks ago, first since 2004, so it has some updates. Unfortunately, there's no easy gem to install. You'll have to download the tar, and then run

sudo ruby install.rb

Of course, you'll run into some problems, unless you have other packages installed:

sudo apt-get install lapack3 lapack3-dev libg2c0-dev

Don't worry, if you don't like it, you can run uninstall. Read INSTALL file for more directions.
I use to wonder how people knew which packages to look for. Apparently, you look at the output and see what files the configure is crapping out on. Then use apt-file to search for which package the file is in. It's one of those basic things that seems not mentioning in hindsight. Like calling "source ~/.bashrc" after you've edited your bash files. No one ever mentions that.

sudo apt-get install apt-file
sudo apt-file update
apt-file list g2c.h

Knowing that, you'll know how to fish, and I'll not post how to install stuff in the future.



  1. This comment has been removed by the author.

  2. There's now a Linux binary for linalg-1.0.0 available at rubyforge

    After I finally got a workable Linux box, there were a few issues building a statically-linked LAPACK (Ubuntu's static libs are hosed, probably since they are relatively unused).

  3. I am running in to troubles installing the dependencies: lapack3, libg2c0-dev, lapack3-dev. I cannot find them on the ubuntu 10.04 repositories. I tried installing the .deb packages from ubuntu. When I got the package libg2c0, it said gcc3.4 not found. I have the latter version gcc4.4, so why am I not able to install stuff? Do I have to get the older version? I am not sure what other programs will be affected then.

  4. Hrm, I don't know. Ubuntu regularly retires packages from the repos. You'll want to check ubuntu's community forums as they're pretty active and helpful over there. I don't know enough about the state of LAPACK itself to be able to help you.

  5. Anyone having issues with libg2c0 on new versions of Ubuntu should just revert to using f2c using these instructions.