In a former post I showed how Gnuplot 4.2.6 could be easily installed on Mac OS X. In the meantime Gnuplot 4.4.0 was released and although the wxWidgets terminal still doesn’t work on Mac OS X, there are the new cairo based terminals which provide png and pdf output. These terminals replace the gd terminals (libgd is not easily installed due it’s dependencies) and the old pdf terminal (which depends on the not-very-free pdflib). Since gif and jpeg (libgd terminal) shouldn’t be used for plots anyways, this is no loss. Since these formats are the ones which I need mainly, I show in this post how we could compile and install Gnuplot with little effort, providing X11, png and pdf terminal (and others which are compiled in anyway).
First we need to download and install the GTK Framework, which was described in this post. Basically you need to:
- Download the GTK_2.18.5-X11.pkg package from http://r.research.att.com/ and install it
- Add to your .profile file in the home directory:
export PATH=/Library/Frameworks/GTK+.framework/Resources/bin:$PATH
- (Re)start Terminal.app and see if
pkg-config cairo --libsworks.
Then download Gnuplot 4.4.0, untar, configure and compile it:
- Download Gnuplot 4.4.0 from Sourceforge.
tar xzf gnuplot-4.4.0.tar.gzcd gnuplot-4.4.0mkdir build && cd build../configure --with-readline=bsd --disable-wxwidgets. In the configure output you should find something likewxt terminal: no (requires C++, wxWidgets>2.6, cairo>0.9, pango>1.10) cairo-based pdf and png terminals: yes
makesudo make install
Gnuplot will be installed in /usr/local/bin and should be ready to be used (if /usr/local/bin is in your path). pngcairo and pdfcairo are the new terminals you can use now. Gnuplot 4.4 has some major improvements so it may worth to install Gnuplot following these instructions.

April 8, 2010 at 06:01
When I run the “make” command, I get the following gibberish (everything works up to that point):
make all-recursive
Making all in config
make[2]: Nothing to be done for `all’.
Making all in m4
make[2]: Nothing to be done for `all’.
Making all in term
make[2]: Nothing to be done for `all’.
Making all in src
Making all in wxterminal
make[3]: Nothing to be done for `all’.
gcc -DHAVE_CONFIG_H -I. -I.. -I../term -I../term -DBINDIR=\”/usr/local/bin\” -DX11_DRIVER_DIR=\”/usr/local/libexec/gnuplot/4.4\” -DGNUPLOT_PS_DIR=\”/usr/local/share/gnuplot/4.4/PostScript\” -DGNUPLOT_JS_DIR=\”/usr/local/share/gnuplot/4.4/js\” -DGNUPLOT_LUA_DIR=\”/usr/local/share/gnuplot/4.4/lua\” -DCONTACT=\”gnuplot-bugs@lists.sourceforge.net\” -DHELPFILE=\”/usr/local/share/gnuplot/4.4/gnuplot.gih\” -DGNUPLOT_X11=\”`echo gnuplot_x11 | sed ‘s,x,x,’`\” -DXAPPLRESDIR=\”/etc/X11/app-defaults/\” -I/usr/X11/include -D_REENTRANT -I/Library/Frameworks/GTK+.framework/Resources/include/cairo -I/Library/Frameworks/GTK+.framework/Resources/include/pixman-1 -I/Library/Frameworks/GTK+.framework/Resources/include/freetype2 -I/Library/Frameworks/GTK+.framework/Resources/include -I/Library/Frameworks/GTK+.framework/Resources/include/libpng12 -I/Library/Frameworks/GTK+.framework/Resources/include/pango-1.0 -I/Library/Frameworks/GTK+.framework/Resources/include/glib-2.0 -I/Library/Frameworks/GTK+.framework/Resources/lib/glib-2.0/include -g -O2 -ObjC -MT alloc.o -MD -MP -MF .deps/alloc.Tpo -c -o alloc.o alloc.c
cc1: error: invalid option argument ‘-ObjC’
make[3]: *** [alloc.o] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Do you know what that means?
April 8, 2010 at 08:37
According to this document: http://developer.apple.com/mac/library/technotes/tn2002/tn2071.html -ObjC is a valid flag for gcc on Mac OS X. Which version of Mac OS X do you have and which version of gcc (just run ‘gcc’). This instructions were tested on Mac OS X 10.5.8 (latest XCode) and Mac OS X 10.6.
April 8, 2010 at 16:18
I have OS X 10.5.8 and GCC 4.4.1 20090623 (prerelease). I just downloaded XCode the other day, so I’m pretty sure it’s the latest.
April 8, 2010 at 19:37
Hi Floyd, I think this is the problem. At least on the Xcode website it is stated that Xcode 3.2.2 is for Snow Leopard only. I’m sure that I installed the latest XCode version (3.1.4) which can be used for 10.5. To download that version go to the Mac Dev Center of developer.apple.com, then click “Developer Downloads” left, then click “Developer Tools” on the right. On this page it says for Xcode 3.2.2 :”It must be installed on Mac OS X 10.6.2 Snow Leopard and higher.” Further down there is XCode 3.1.4 for “Mac OS X 10.5.0″. I have only gcc version 4.0.1 (Apple Inc. build 5493) and gcc version 4.2.1 (Apple Inc. build 5577). So I’m pretty sure you have the wrong XCode version installed. If so uninstall Xcode (http://macdevelopertips.com/xcode/how-to-uninstall-xcode.html) and install 3.1.4.
HTH,
Werner
April 8, 2010 at 19:43
Or you installed gfortran or similar earlier and you are using not the gcc version of Xcode (and which doesn’t know the -ObjC option). Check your PATH environment variable if there is some path you want to remove. Use also “which gcc” to find out where the gcc binary is – mine is in /usr/bin.
HTH,
Werner
April 9, 2010 at 00:30
Well I have XCode 3.1.4 installed, so that’s not the problem. I installed gfortran from http://hpc.sourceforge.net/ and the name of the file was “gcc-leopard-intel-bin.tar.gz”.
What do you mean the gcc version of XCode? I didn’t know there was more than one version haha!
My gcc is installed in /sw/bin (because I have fink [http://www.finkproject.org] installed and it uses /sw.
How would I check my PATH variable? I’m new to the whole compiling thing (I’m having to do this for a class), and I’m not sure what I would need to change to get it to work.
Sorry for the noobishness haha.. Thanks for the help!
April 9, 2010 at 07:59
Hi Floyd, that’s not hard. Edit your .profile file in the home directory:
nano ~/.profile
and there must a line like
export PATH=/sw/bin:$PATH
comment it with
# export PATH=/sw/bin:$PATH
save with Ctrl-O and exit nano with Ctrl-X (or us any other text editor). Restart Terminal.app. Now if you run gcc it should give you
gcc version 4.0.1 (Apple Inc. build 5493)
as version information. Remove the gnuplot directory and restart from scratch. After gnuplot is installed you can uncomment the PATH line in your .profile again to have fink again in your path. You’re using then the other gcc version again. Maybe you want to remove the fortran version you have from HPC, since att claims it is buggy: http://r.research.att.com/tools/ – they provide a (better?) build of the fortran compiler.
April 9, 2010 at 13:12
I get a couple of erros similar to:
“wxDialogBase::SetFocusIgnoringChildren()”, referenced from:
vtable for wxtConfigDialogin wxt_gui.o
with snow leopard, i686-apple-darwin10-gcc-4.2.1
April 9, 2010 at 13:18
Paul, make sure that the wxt terminal is disabled. You need to append “–disable-wxwidgets” to the configure options. The wxt terminal doesn’t work on Mac OS X. Make sure, that configure outputs “wxt terminal: no” somewhere at the end.
HTH,
Werner
April 9, 2010 at 20:32
test -r /sw/bin/init.sh && . /sw/bin/init.sh
test -r /sw/bin/init.sh && . /sw/bin/init.sh
export DYLD_LIBRARY_PATH=/sw/lib:$DYLD_LIBRARY_PATH
export PATH=/Library/Frameworks/GTK+.framework/Resources/bin:$PATH
The above is my entire .profile file… the DYLD_LIBRARY_PATH variable is simply a pointer to find libraries to allow me to run a.out files from /sw/bin. Should I comment out the GTK+ line instead?
April 9, 2010 at 21:11
Floyd, no the test -r … line needs to be commented. I think /sw/bin/init.sh sets the PATH (have a look there). It’s just temporary just to compile gnuplot. then revert the changes.
April 9, 2010 at 23:57
Ah that’s awesome! Gnuplot is now installed, and plots in Aquaterm perfectly. Thanks for your detailed help!
April 10, 2010 at 11:25
I copied and pasted: ‘../configure –with-readline=bsd –disable-wxwidgets’
from the text above, that did not work, but retyping it gave me a fule working 4.4 on snow leopard. Thanks for the comments.
April 30, 2010 at 15:41
for floyd mased
how have been able to use it with aquaterm? for me it does not work as aquaterm is in 32bit ….
April 30, 2010 at 15:58
Hi Nicola,
you could try to force gcc to compile a 32bit application of Gnuplot on Mac OS X which then should be able to link to aquaterm. I think this should do the trick:
export CFLAGS=”-arch i386 -m32″
export CXXFLAGS=”$CFLAGS”
(taken from http://wiki.winehq.org/MacOSX/Building). Start with a new build/source directory, so that no old configuration files mess up you new build. Let us know if this works.
Regards,
Werner
May 31, 2010 at 13:50
Thank you !
gnuplot 4.4 on snow leopard installed with aquaterm support thanks the tricks mentioned here:
export CFLAGS=”-arch i386 -m32″
export CXXFLAGS=”$CFLAGS”
../configure –with-readline=bsd
But did not succeed with gnu readline support, sic .
May 31, 2010 at 14:03
Actually I think using the -m32 flag is no the best way. It’s better to use the older gcc toolchain 4.0, which still defaults to 32bit compilation, e.g.
export CC=gcc-4.0
export CXX=g++-4.0
export LD=g++-4.0
export CFLAGS=”-arch i386″
export CXXFLAGS=”$CFLAGS”
../configure –with-readline=bsd (these are two – in front of with)
look here: http://wiki.wxwidgets.org/Development:_wxMac
July 1, 2010 at 06:26
When I run the make command I am getting the following:
“_wxEVT_MOTION”, referenced from:
__static_initialization_and_destruction_0(int, int)in wxt_gui.o
“wxWindow::ClearBackground()”, referenced from:
vtable for wxtPanelin wxt_gui.o
vtable for wxCheckBoxBasein wxt_gui.o
vtable for wxStaticTextBasein wxt_gui.o
vtable for wxSliderBasein wxt_gui.o
vtable for wxButtonBasein wxt_gui.o
“wxFrameBase::OnInternalIdle()”, referenced from:
vtable for wxtFramein wxt_gui.o
“wxFrameBase::SetStatusWidths(int, int const*)”, referenced from:
vtable for wxtFramein wxt_gui.o
“wxMessageBox(wxString const&, wxString const&, long, wxWindow*, int, int)”, referenced from:
wxtFrame::OnHelp(wxCommandEvent&) in wxt_gui.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[3]: *** [gnuplot] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Do you know what is missing?
July 1, 2010 at 06:28
Everything works fine untill I run the “make” command were I get this error:
“_wxEVT_MOTION”, referenced from:
__static_initialization_and_destruction_0(int, int)in wxt_gui.o
“wxWindow::ClearBackground()”, referenced from:
vtable for wxtPanelin wxt_gui.o
vtable for wxCheckBoxBasein wxt_gui.o
vtable for wxStaticTextBasein wxt_gui.o
vtable for wxSliderBasein wxt_gui.o
vtable for wxButtonBasein wxt_gui.o
“wxFrameBase::OnInternalIdle()”, referenced from:
vtable for wxtFramein wxt_gui.o
“wxFrameBase::SetStatusWidths(int, int const*)”, referenced from:
vtable for wxtFramein wxt_gui.o
“wxMessageBox(wxString const&, wxString const&, long, wxWindow*, int, int)”, referenced from:
wxtFrame::OnHelp(wxCommandEvent&) in wxt_gui.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[3]: *** [gnuplot] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Do you know what is missing?
July 1, 2010 at 06:29
Sorry for the duplicates since I was getting an error!!