The So-Help-Me-God Edition
If you are in the fortunate position to be a lucky owner of a spiffy new Macbook, I salute you! In my humble opinion there could not be a finer breed of computer. Savor it, my friend!
However, if you are in the unfortunate position of needing to implement algorithms and plots in GNU Octave, I pity you. It is your fate to run through the gauntlet of Unix dependency hell that is getting open source software to work on a closed source operating system.
But I have good news! Hopefully, I have now exposed all the booby traps that Mountain Lion has set for you, and I've discovered the secret command-line incantations necessary to avoid them. Yes, much like Indiana Jones and the Last Crusade, I will now deftly disarm the traps so that you may pass freely into the chamber of the Holy Grail1. Choose wisely.
- First, install XQuartz. In the past this came installed on OS X, but as of Mountain Lion it is no longer included. So go fix that.
- You will also need the Xcode Command Line Tools if you don't already have them. Both Homebrew and XQuartz need this to work.
- Now you are ready to install Octave from Homebrew:2
Shell12$ brew tap homebrew/science$ brew install octave
If you don't know what Homebrew is, then do me a favor and slap yourself a couple times. Install Homebrew now; thank me later.
Wow, Neil, that was easy! That's it, huh?
NO, YOU FOOL!
- Octave claims to have native drawing support using FLTK, but I haven't been able to get it working yet. We'll rely on gnuplot instead, which must be installed separately:
Shell1$ brew install gnuplot
- Now edit your Octave startup file or create a new one:
Shell1$ vim ~/.octaverc
and add the line:MATLAB1setenv GNUTERM x11
(btw, to save and exit vim, type ':wq', or to exit without saving, type ':q')
- Now for the ultimate fix: reboot your machine! Yep, until you restart your Mac, Octave will be unable to launch XQuartz on its own, and you won't be able to plot anything.
- Once you're back in, open the terminal, fire up Octave, and plot a sombrero(). You're all set!
- The Holy Grail of Octave? Okay, not the greatest analogy.
- If you're having trouble with this step, see: Octave for OS X