Install Gnuplot 4.4.0 on Mac OS X

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:

  1. Download the GTK_2.18.5-X11.pkg package from http://r.research.att.com/ and install it
  2. Add to your .profile file in the home directory:
    export PATH=/Library/Frameworks/GTK+.framework/Resources/bin:$PATH
    
  3. (Re)start Terminal.app and see if pkg-config cairo --libs works.

Then download Gnuplot 4.4.0, untar, configure and compile it:

  1. Download Gnuplot 4.4.0 from Sourceforge.
  2. tar xzf gnuplot-4.4.0.tar.gz
  3. cd gnuplot-4.4.0
  4. mkdir build && cd build
  5. ../configure --with-readline=bsd --disable-wxwidgets
    In the configure output you should find something like

      wxt terminal: no (requires C++, wxWidgets>2.6, cairo>0.9, pango>1.10)
      cairo-based pdf and png terminals: yes
  6. make
  7. sudo 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.

47 thoughts on “Install Gnuplot 4.4.0 on Mac OS X

  1. 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?

  2. 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.

  3. 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

  4. 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

  5. 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!

  6. 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.

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

  8. 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

  9. 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?

  10. 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.

  11. Ah that’s awesome! Gnuplot is now installed, and plots in Aquaterm perfectly. Thanks for your detailed help!

  12. 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.

  13. for floyd mased
    how have been able to use it with aquaterm? for me it does not work as aquaterm is in 32bit ….

  14. 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

  15. 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 .

  16. 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

  17. 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?

  18. 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?

  19. Hi Werner,

    I am new to mac and unix.
    I just a new mac with snow leopard..

    I wanted to install gnuplot, and followed your posts. But for GTK, after a google check, I followed this link http://sourceforge.net/apps/trac/gtk-osx/wiki/Build#Prerequisites for the installation, just before the example given for building GMP.

    I have now in my home directory a directory “gtk”.

    Could you please let me know what I should do now?

    Thanks a lot,

    Radjes

  20. Hi Alexander,

    in your gtk directory, there must be a bin directory. Add this to your path, e.g. in your .profile file add

    export PATH=…/gtk/bin:$PATH

    restart your terminal. If you run “which pkg-config” a path to pkg-config in the gtk/bin directory must be shown. If you run “pkg-config –libs cairo” a path to your gkt libs directory must be shown. Rerun the configure script of gnuplot. Your gtk version should now be picked up.

    WErner

  21. Hi Werner,

    I am already trying old day long to get this running. I get the exactly same message as Ahmed above.
    Do you have an idea what the problem might be?

    Cheers, from Down Under

  22. Huh,

    I got the problem:

    instead of “../configure –with-readline=bsd –disable-wxwidgets”
    i copy paste “../configure –with-readline=bsd –disable-wxwidgets.”

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!No dot after the command!!!!!!!!!!!!!!!!!!!!!!!!

    Might be useful for those who are not familiar with the comments.

    Thanks for providing the space, Werner.

  23. Hi Krzysztof, thanks for your comments. I changed the post above, so that nobody will fall into this trap again. Sorry for that.

    Werner

  24. I understand everything until this point:
    Gnuplot will be installed in /usr/local/bin and should be ready to be used (if /usr/local/bin is in your path)

    I want to be careful when editing .profile in my home directory. What exact line should be in this file so that I may execute gnuplot?

  25. Hi Kristen,

    in you .profile should be the following line

    export PATH=/usr/local/bin:$PATH

    restart the terminal and /usr/local/bin is in your path. You can check that with the terminal command “env”.

    HTH,
    Werner

  26. Werner, thank you for your detailed instructions how to install gnuplot under OSX 10.6. The only think that didn’t work was adding “export PATH=/Library/Frameworks/GTK+.framework/Resources/bin:$PATH” into my .profile file. But adding it to my .bash_profile file made everything work nicely.
    By the way, I dowloaded and installed gnuplot 4.4.2 with apropriate changes for tar and cd commands. (MacBook Pro, OSX 10.6.5)
    Hope this might be isefull to somebody,
    Sime

  27. Thanks a lot Werner. I had the same problem that Floyd Maseda had and I followed your instructions and it worked perfectly.

  28. Thanks for the straightforward and clear instructions!

    A point I’d love to see clarified:

    “3. (Re)start Terminal.app and see if pkg-config cairo –libs works.”

    What does “works” mean here? It returns

    “-L/Library/Frameworks/GTK+.framework/Resources/lib -lcairo”

    is this good, bad, good enough?

    I guess I’ll continue with the installation and see if it goes smoothly or dies horribly! (-:

    Thanks again,
    -Vijay

  29. Hi, Werner,

    I’m trying to install the gnu plot under lion 10.7.1. I have Xcode 4.1
    I get the exact error as Floyd in the first comment.
    I commented out the .profile file but still the same error.
    This is my .profile file:
    ##
    # DELUXE-USR-LOCAL-BIN-INSERT
    # (do not remove this comment)
    ##
    #echo $PATH | grep -q -s “/usr/local/bin”
    #if [ $? -eq 1 ] ; then
    # PATH=$PATH:/usr/local/bin
    # export PATH
    #fi
    export PATH=/Library/Frameworks/GTK+.framework/Resources/bin:$PATH

    Can you help?

  30. Hi Jan, there might be problems with 32bit and 64bit builds. GTK is definitely 32bit and gcc on Mac OS X 10.7 is automatically 64bit. You should run the configure command with the “-arch i386” option, which should tell the configure script to compile everything 32bit. I’ll look into this issue and write a new blog entry if necessary.

  31. Hi Werner
    I am trying to install gnuplot 4.4.3 in my mac ox 10.5.8.
    My gcc is 4.0.1.
    (I have gnuplot 4.0.1 in my computer at this moment, but it was installed by someone else some while ago.)
    There is error showing up when I use “make install”.
    I have gone through all the discussions in this page, and haven’t got any ideas. Would you have a look at my problem?
    evoltheo013:gnuplot-4.4.3 huangadmin$ make install
    Making install in config
    make[2]: Nothing to be done for `install-exec-am’.
    make[2]: Nothing to be done for `install-data-am’.
    Making install in m4
    make[2]: Nothing to be done for `install-exec-am’.
    make[2]: Nothing to be done for `install-data-am’.
    Making install in term
    make[2]: Nothing to be done for `install-exec-am’.
    test -z “/usr/local/share/gnuplot/4.4/js” || .././install-sh -c -d “/usr/local/share/gnuplot/4.4/js”
    mkdir: /usr/local/share/gnuplot: Permission denied
    make[2]: *** [install-jsDATA] Error 1
    make[1]: *** [install-am] Error 2
    make: *** [install-recursive] Error 1

  32. Sorry. I didn’t use sudo make install in my last message.
    But after I used it, the problem is still there.
    Here is the new update.

    /usr/bin/install -c -m 644 gnuplot.1 ‘/usr/local/share/man/man1′
    make install-data-hook
    make[3]: Nothing to be done for `install-data-hook’.
    Making install in demo
    make[2]: Nothing to be done for `install-exec-am’.
    make[2]: Nothing to be done for `install-data-am’.
    Making install in tutorial
    make[2]: Nothing to be done for `install-exec-am’.
    make[2]: Nothing to be done for `install-data-am’.
    Making install in share
    Making install in LaTeX
    make[3]: Nothing to be done for `install-exec-am’.
    test -z “/usr/local/usr//usr/local/texlive/2008/../texmf-local/tex/latex/gnuplot” || ../.././install-sh -c -d “/usr/local/usr//usr/local/texlive/2008/../texmf-local/tex/latex/gnuplot”
    /usr/bin/install -c -m 644 gnuplot.cfg gnuplot-lua-tikz.sty ‘/usr/local/usr//usr/local/texlive/2008/../texmf-local/tex/latex/gnuplot’
    make install-data-hook
    test -n “” || texhash
    texhash: Updating /usr/local/texlive/2008/../texmf-local/ls-R…
    texhash: Updating /usr/local/texlive/2008/texmf/ls-R…
    texhash: Updating /usr/local/texlive/2008/texmf-config/ls-R…
    texhash: Updating /usr/local/texlive/2008/texmf-dist/ls-R…
    texhash: Updating /usr/local/texlive/2008/texmf-doc/ls-R…
    texhash: Updating /usr/local/texlive/2008/texmf-var/ls-R…
    texhash: Done.
    make[3]: Nothing to be done for `install-exec-am’.
    test -z “/usr/local/share/gnuplot/4.4/app-defaults” || .././install-sh -c -d “/usr/local/share/gnuplot/4.4/app-defaults”
    /usr/bin/install -c -m 644 Gnuplot ‘/usr/local/share/gnuplot/4.4/app-defaults’
    make[2]: Nothing to be done for `install-exec-am’.

  33. Are you sure that the install process went wrong? “Nothing to be done” just means, that in that directory, there is nothing to be installed. Check if gnuplot is in /usr/local/bin and add this to your path:

    export PATH=/usr/local/bin:$PATH

    add this to your .profile file.

    HTH,
    WErner

  34. Thanks for link . It help my compilation errors.

    I managed to get gnuplot 4.4.3 and os X 10.6.8 SL to work on x11. Its on my mac mini. I ran all the demo files and worked fine on x11.
    I used gnuplot for figures.

    Q: How to set terminal to aqua Mac os X. I may need the plotted output to latex pdf environment. I need to run TexShop with figure environment.
    Thanks a lot.

  35. You can change the terminal with the command

    set term aqua

    enter

    set term

    to get a list of all available terminals.

  36. Hi Werner,
    I install gnuplot 4.4 like your way, but i don’t have term aqua or wtx enhanced be default and the list of set term don’t appear.

    Any solution?

    Thanks for your post and sorry for my poor english

  37. Hello,
    I want to install gawk 3.1.1 on my machine mac version 10.5.8,i followed these steps:
    cd gawk-3.1.1
    ./configure –prefix=$HOME
    make
    make install
    but i have these errors:
    Making install in test
    make[2]: Nothing to be done for `install-exec-am’.
    make[2]: Nothing to be done for `install-data-am’.

    i have gcc 4.0.1 installed on my pc and xcode 3.1.4
    thx for ur help.

  38. Thanks so much, you made it so simple and it worked perfectly!
    It looked at so many pages with their ways that made no sense!

    For anyone else trying this, something that isn’t included:

    You need to temporarily set some admin password for the command

    sudo make install

    This is because it will ask for a password that can’t be blank, you need to type your password in even though it won’t show up on the screen, then after hitting enter, terminal gives some long, strange return, try opening gnuplot then.

  39. Desperately casting around to try and get actually plotting.

    Earlier I had done a simple gnuplot install but before installing the latest Aquaterm and GTK libraries. That worked, but of course I lacked certain terminals. So I uninstalled gnuplot, got a fresh copy of 4.6.1, followed the recipe given above, and got happily through the configure step using

    ./configure –with-readline=bsd –disable-wxwidgets

    That was peachy and aquaterm and pdfcairo terminals were there.

    But, trying make returned the following:

    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’.
    Making all in qtterminal
    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.6\” -DQT_DRIVER_DIR=\”/usr/local/libexec/gnuplot/4.6\” -DGNUPLOT_SHARE_DIR=\”/usr/local/share/gnuplot/4.6\” -DGNUPLOT_PS_DIR=\”/usr/local/share/gnuplot/4.6/PostScript\” -DGNUPLOT_JS_DIR=\”/usr/local/share/gnuplot/4.6/js\” -DGNUPLOT_LUA_DIR=\”/usr/local/share/gnuplot/4.6/lua\” -DCONTACT=\”gnuplot-bugs@lists.sourceforge.net\” -DHELPFILE=\”/usr/local/share/gnuplot/4.6/gnuplot.gih\” -DGNUPLOT_X11=\”`echo gnuplot_x11 | sed ‘s,x,x,’`\” -DXAPPLRESDIR=\”/etc/X11/app-defaults/\” -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: argument to ‘-O’ should be a non-negative integer
    make[3]: *** [alloc.o] Error 1
    make[2]: *** [all-recursive] Error 1
    make[1]: *** [all-recursive] Error 1
    make: *** [all] Error 2

    I have Xcode 3.2.6 and the developer tools on this machine, but I also have a more recent gcc in /usr/local/bin (4.6.0). Maybe it should be obvious to me from the above discussion, but I am running afoul of a compiler-cersion issue? What I don’t understand is why the earlier gnuplot install worked, the one time…

  40. Update and duh moment:

    Almost exactly as Werner said, temporarily blocking my path to the new gcc brought the Xcode version into play, and that let gnuplot compile perfectly.

    Sorry to take up all that space with the long question, but hopefully this will help someone else get it right — sometimes it’s just the way I learn.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.