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.


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.


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 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:

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

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

gnuplot_SOURCES += binary.c

and delete these lines also:

gnuplot_SOURCES += wxterminal/gp_cairo.c wxterminal/wxt_gui.cpp

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.


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