Installing Octave Packages in Snow Leopard

• Chris Liscio

If you're anything like me, and you rely on Octave in your work, then not having a working copy can be very frustrating.

I stumbled on, not one, but two issues plaguing Octave in Snow Leopard.

First, it appears that installing Octave via macports is busted. Actually, you'll get stuck while building gcc45. There's already an open macports bug for this (see the huge list of open issues), so it'll probably get solved soon. I don't normally install Octave via macports, but when I got stuck installing packages I tried to install via this route.

Second, when you try installing packages from octave forge from within the pre-made Octave binary, the build fails with some messages about mismatched architectures. This is because GCC is defaulting to build x86_64, but Octave is built as i386 for the time being.

I typically prefer to use the pre-made binaries. It's the quickest route to getting Octave up and running on your system, and installing packages is quite painless. So, I decided to hack around until I could determine a quick solution to the problem. Here's my solution:

  1. Open /Applications/Octave.app/Contents/Resources/bin/mkoctfile /usr/local/bin/mkoctfile
  2. Change CFLAGS, FFLAGS, CPPFLAGS, CXXFLAGS, and LDFLAGS so that they all contain -arch i386. I put it at the beginning, so it looks like this:
  3. CFLAGS="-arch i386 -I${ROOT}/include[...]
    FFLAGS="-arch i386 -I${ROOT}/include[...]
    CPPFLAGS="-arch i386 -I${ROOT}/include[...]
    CXXFLAGS="-arch i386 -I${ROOT}/include[...]
    LDFLAGS="-arch i386 -L${ROOT}/lib[...]

I hope this helps someone. I'm pretty sure it's not the correct way to solve the problem, but I just don't have the time right now to figure out the proper solution, submit a patch, etc.

Update 20090924—Changed location of mkoctfile. On my main machine, it's apparent that I still have some holdovers from when I was messing around with the macports version of Octave. While setting up my laptop with the Octave.app package, I found out where mkoctfile was supposed to live. Apologies for the error.