Compiling gnuplot on Mac OS X

September 2006

This document explains how to compile gnuplot version 4.1 on Mac OS X. But before compiling gnuplot you must install some other software.

gnuplot and Fink

I had many problems trying to compile gnuplot using tools and libraries downloaded using fink. Eventually I had to re-install Mac OS X so that I had a fink-free system.

gcc

I use gcc 3.3 to compile everything. There seems to be a problem with the way gcc 4.x handles objective C. I installed the apple developer tools distributed by Apple in the xcode disk image, but I didn't install xcode itself.

Aquaterm

If you want to use the aquaterm terminal with gnuplot (and you DO want to use aquaterm), then first you must download and install aquaterm. Download from the disk image (dmg) file from the sourceforge project page http://sourceforge.net/projects/aquaterm/. Open the disk image and click on the package file to install.

PNG and GIF with TrueType

For png and gif support you need to compile gd. Here is a really good tutorial about installing gd on Mac OS X. My directions will be much briefer.

If you want PNG and GIF support (and you DO want png and gif) then you must download, compile, and install a bunch of packages. Here are the links:

http://fontconfig.org/release/fontconfig-2.4.1.tar.gz

http://download.savannah.gnu.org/releases/freetype/freetype-2.2.1.tar.gz

http://www.ijg.org/files/jpegsrc.v6b.tar.gz

http://www.zlib.net/zlib-1.2.3.tar.gz

http://prdownloads.sourceforge.net/libpng/libpng-1.2.12-no-config.tar.gz?download

http://pkgconfig.freedesktop.org/releases/pkg-config-0.21.tar.gz

http://www.boutell.com/gd/http/gd-2.0.33.tar.gz

For each of these packages you must do the following:

bash$ tar -xzvf {packagename}.tar.gz
bash$ cd {packagename}
bash$ ./configure
... lots of configure messages ...
bash$ make
bash$ sudo make install

As far as I remember, this is the order that you must install in: fontconfig, freetype, jpegsrc, zlib, libpng, pkg-config, gd. There may be some flexibility in the order, but it is important to install gd last.

And there is an extra step for fontconfig. For some reason, when I installed fontconfig it failed to copy its header files. So here's how to copy the header files:

bash$ mkdir /usr/local/include/fontconfig
bash$ cp fontconfig-2.4.1/fontconfig/* /usr/local/include/fontconfig

Compiling gnuplot

Once all that is done you should be ok to compile gnuplot. Download and extract the v4.1 source code archive http://gnuplot.sourceforge.net/development/binaries/.

Before compiling you must edit the src/Makefile.am file. Open that file in your favourite editor and delete the following lines:

if INCLUDE_BINARY_C
gnuplot_SOURCES += binary.c
endif

and delete these lines also:

if BUILD_WXWIDGETS
gnuplot_SOURCES += wxterminal/gp_cairo.c wxterminal/wxt_gui.cpp
endif

now you can compile gnuplot:

bash$ ./prepare
bash$ ./configure –exec-prefix=/usr –with-x=no –without-tutorial CFLAGS=-DDEFAULTTERM=\\\”aqua\\\”
bash$ make
bash$ sudo make install

TrueType Fonts

So I compiled gd and gnuplot successfully with truetype support, but gnuplot can't find any fonts! gd can't find the fonts because something is wrong with fontconfig. The easy solution is to define the GDFONTPATH environment variable. But then I had another problem: the Apple fonts wouldn't work. So here's how I fixed both problems. First, I defined the GDFONTPATH environment variable:

export GDFONTPATH=~/.fonts

Then I copied the fonts from the /usr/local/fonts/truetype directory on my linux box to ~/.fonts on my Mac Mini.

My gnuplot installation is working fairly well now, except I might go back and recompile freetype with kerning.

Help!

If it doesn't work then you can send me an email at andrew@howlettNOSPAM.net. Remove the NOSPAM characters from that address and your email should go to me.