gnuplot with AquaTerm on OSX Snow Leopard

The gnuplot graphing utility has always had excellent support for multiple terminal types. While the X11 terminal is a satisfactory GUI view for the graphs, I prefer to use the AquaTerm terminal on OSX as it is more ‘Mac-like’ and feels more natural.

Also, I do prefer to compile gnuplot by myself on OSX rather than downloading the pre-packaged binaries – as this gives me more control over the compilation (including getting around the stupid Apple readline bug – where Apple has essentially shipped a broken readline by using libedit to emulate the non-existent libreadline).

This local compile requires that AquaTerm be installed so that the library dependencies for aquaterm exists in:

terminal.png

and the corresponding headers are available at:

1____terminal.png
In addition, the AquaTerm.app itself resides in /Applications.

However, on OS X Snow Leopard, there is a catch – the version of AquaTerm is 32 bit, whereas the default compilation of gnuport results in a 64-bit version – which is not able to load the 32-bit libaquaterm dynamic libraries.

littlesnapper.png

In such a case, the gnuplot compilation does succeed – however, the default terminal becomes the X11 version – which is back to square-one.

A darwinports port does exist for gnuplot – however, as mentioned in an earlier post, this port seems to depend on half of the port repository (i.e., a ton of stuff you do NOT want gets installed as well).

However, there is a easier way to get around this situation. Here’s how.

  1. First install the default binary for AquaTerm from SourceForge and install normally. This step is to basically setup the right folders and symlinks so that you do not have to muck with these later
  2. Now install AquaTerm again from Darwinports – this port has the correct patches needed – and more importantly – builds a 64 bit version by default. This will also install the application under /Applications/MacPorts/

2____terminal.png

  1. Now comes the fun part. We will replace two folders from the darwinports version to the previously installed AquaTerm.
    • Step 1: Replace /Library/Frameworks/AquaTerm.framework with /opt/local/Library/Frameworks/AquaTerm.framework. This will ensure that the correct 64 bit AquaTerm libraries get referenced by the gnuplot compilation
    • Step 2: Replace /Applications/AquaTerm.app with /Applications/MacPorts/AquaTerm.app. This will ensure that the correct 64-bit AquaTerm binary is in the correct location
    • Step 3 (Optional): You can now uninstall the darwinports version by running sudo port uninstall aquaterm from a terminal window
  2. Download the source code for gnuplot and extract the same.
  3. Run ./configure (using a command line parameter to ignore the broken Apple readline) and then make and make install (install will happen in /usr/local)

3____terminal.png

That’s it! The compilation should now succeed and gnuplot will be linked with the correct 64-bit aquaterm dynamic library. Enjoy!

4____terminal.png
figure0.png

Advertisement

Dependency hell with darwinports

I have had the need to produce charts and graphs for my work lately – and wanted to start using gnuplot. Should be easy right?  After all, there is a darwinports port available, and install should have been a breeze, with just a:

sudo port install gnuplot

Or so I thought.  For some unknown &!@^% reason, darwinports with its immense intelligence decided that it needed to download 75 other ports that I did not ask for, including its own version of X11, even though Apple does provide a perfectly decent implementation that I have installed.

And guess what, there is not way to uninstall these 75 at one go either. You will need to uninstall one or a few at a time using the

sudo port uninstall <junk>

command and hope that the dependency hell does not bite you … or else it is multiple rounds of fiddling with the command line and hoping that the current uninstall invocation is the last round. Argh!

The solution (to installing gnuplot, that is) was much simpler. After cleaning out the junk that darwinports installed, I proceeded to download the latest gnuplot source and the excellent Aquaterm for a OSX friendly render terminal.

After installing Aquaterm (which is a simple dmg, drag-to-Applications and you are done install), I untarred the gnuplot source, ran the following standard configure/build commands, and was running gnuplot in less than 5 minutes.

./configure –with-readline=builtin
make
make test
# This launches Aquaterm and runs some nice tests which demonstrate gnuplot’s capabilities
sudo make install

Take that, darwinports!

P.S.:  The bit about using the builtin readline is necessary on my version of OSX (10.5.7) as there is some nasty interplay with the system provided readline version.