Scientific Plotting on Mac OS X (Intel) using Gnuplot and Plot

Gnuplot under AquaTermAfter having successfully moved my LaTeX publishing environment to the new Macbook, all that was left was a working Intel build of gnuplot 4.1.0 (which has some nice new features over 4.0). This was actually not quite easy, so I’m going to document my steps for producing a Universal Binary of Gnuplot 4.1 here for future reference.

You might also take a look at Plot. It’s a first-rate freeware plotting tool with some really great features (think ProFit or GRACE), AppleScript support, and a full-blown layout engine. All this is nicely integrated in a great looking Mac OS X GUI. I really love it.

How to Build and Install Gnuplot 4.1.0 on Mac OS X:

  1. Install AquaTerm. It’s currently at version 1.0.1 (built July 31, 2006) and a universal binary! Here the direct download link.
  2. Optionally, install Apples’s X-Windows (X11). It’s on your Mac OS X setup disk as an additional package. You do not need X11 to build or run Gnuplot. However, the pm3d mouse support for rotating and zooming is only available on X11 (i.e. not in AquaTerm).
  3. Install the Apple Developer CD. We require the GNU compiler and tools (XCode and the Apple Documentation is not required).
  4. Get Gnuplot 4.1.x from the Development Page. You might download the source from CVS. Or, as I did, download a source snapshot as a convenient .tar.gz archive. These archives can be found here. Unpack the archiv and you will have a folder named “gnuplot” on your Desktop or in your home directory.
  5. Now for the fun part. The sources have to be prepared, which would yield the “configure” script. To prepare we use the command ./prepare. However, you will get an error like

    Use of uninitialized value in concatenation (.) or string at /usr/bin/automake line 8449.: am_gnuplot_OBJECTS was already defined in condition INCLUDE_BINARY_C_TRUE, which is implied by condition TRUE

    Some part of the preparation process failed.
    Please refer to INSTALL for details.

    To fix the error, two modifcations in the file “src/Makefile.am” are required. Search for these two if-blocks and delete them or comment them out:

    if INCLUDE_BINARY_C
    gnuplot_SOURCES += binary.c
    endif

    and

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

    I had them at line 44-46 and 73-75.
    Now run ./prepare; it should finish without any errors this time.

  6. Now call the configure script. If you have AquaTerm installed but not X11, then use

    ./configure -with-x=no --without-tutorial CFLAGS=-DDEFAULTTERM=\\\"aqua\\\"

    With X11 installed, instead use

    ./configure --without-tutorial

  7. Run make and then sudo make install
  8. Try the demos, like gnuplot demo/all.dem

24 Comments »

  1. John said,

    August 8, 2006 @ 10:02 pm

    Thanks for posting this. I was just trying to get a version of gnuplot that played well with the new Aquaterm binary. I would not have figured out the problems with the Makefile.am in src.

  2. John said,

    August 9, 2006 @ 11:26 pm

    Well, this actually does not work for me. The make command errors out. I am not sure if this is a problem with wxwidgets, but it seems likely. Adding –disable-wxwidgets to the configure circumvented the problem.

  3. maba said,

    August 10, 2006 @ 2:36 am

    John, thanks for your tip! (However, I just re-run the steps and *for me* the –disable-wxwidgets switch is not required to build gnuplot without errors.)

  4. Andrew Howlett said,

    September 11, 2006 @ 6:38 am

    Martin, thanks for these instructions. I had some problems compiling aquaterm support. I installed aquaterm using fink so I had to add these switches to the configure command: CPPFLAGS=-I/sw/include LDFLAGS=-L/sw/lib

  5. Andrew Howlett said,

    September 12, 2006 @ 3:55 am

    Also, be it known that gnuplot should be compiled with gcc-3.3. Gcc 4 handles objective C differently.

    later,
    andrew.

  6. Andrew Howlett said,

    September 15, 2006 @ 8:56 pm

    More comments!

    If you want to use the gnuplot png terminal, then you need to download, configure, compile and install several libraries BEFORE you compile gnuplot. The libraries are libgd, libpng and maybe zlib.

  7. Andrew Howlett said,

    September 16, 2006 @ 3:23 am

    One last comment. Unfortunately I can’t edit or delete the previous comments.

    Turns out I needed to install more libraries and manually copy some files to get png support. So I uploaded a short list of instructions to my web page. The URL is below. If this reply system scrubs URLs, then click on my name above to go to my web page, then look in the Mac OS X stuff section.

    later,
    andrew.

  8. Philip Fowler said,

    October 26, 2006 @ 7:02 pm

    Works as described for me.

    Can anyone work out how to turn on autocomplete in the gnuplot terminal so one doesn’t have to type out the filenames each time?

  9. Richard Martin-Nielsen said,

    November 22, 2006 @ 4:21 am

    These instructions worked well. With reference to Philip Fowler’s comment, I added “–with-readline=gnu” as an option in the .configure command, having first checked that fink had already installed the gnu readline library. (I use fink for various other bits of my unix-like installs.)

    My final command, then, was
    ./configure –with-readline=gnu –program-suffix=-dev –without-tutorial CFLAGS=-DEFAULTTERM=\\\”aqua\\\”

    I wished the suffix so that I wouldn’t clobber my existing 4.0 installation, but I kept aquaterm as my terminal though I have X11 installed (every so often I do use X11, but I much prefer aquaterm for most things).

    Having readline functionality built in will likely make 4.1 my default gnuplot. Thanks again for the various comments and advice on this process.

  10. Eugene said,

    December 6, 2006 @ 7:46 am

    Hi.

    Stumbled onto this website. IN the process of (being forcibly :() migrating from linux after 20 years. Your how-to was excellent. Thanks!

    E.

  11. Rosario said,

    December 25, 2006 @ 3:03 pm

    Hi.

    I’ve got this error message while compiling
    /usr/bin/ld: can’t locate file for: -lgcc_s.10.4

    I’ve MAC OS X 10.4.8,
    any ideas ?
    many thanks

    R.

  12. Rodger said,

    February 9, 2007 @ 11:50 pm

    Hi: different route.. installed xcode, installed fink and inthe process of using fink to put in octave I got gnuplot.. rather painless.. so I run it all through X11

  13. Nick Edwards said,

    April 4, 2007 @ 1:58 am

    Can’t find the prepare script. I’m probably being really dumb but I can’t see it anywhere

  14. florian steiner said,

    May 1, 2007 @ 12:41 pm

    I have the same problem like nick.
    where is the “prepare” script?

  15. Patrick Coppock said,

    May 15, 2007 @ 5:59 am

    Like Nick and Florian above, or maybe worse, I don’t know how to run the ./prepare script.

  16. zorg said,

    June 5, 2007 @ 8:18 pm

    I suspect you don’t get ./prepare because you didn’t get the cvs snapshot. If you look in the FAQ, it tells you that you need to run prepare if you get the latest CVS. You probably just got the version on the sourceforge page, where you’re supposed to start with ./configure ….

  17. erpfei said,

    September 12, 2007 @ 4:45 pm

    Hi, My MacBook for some reason did not come with the Developer CD, so I thought I’d check for downloads (http://developer.apple.com/tools/download/). Which files specifically should I be looking for? Thanks much!

  18. StarSiriuS‵ reSearch noteS » Blog Archive » Install Octave, Gnuplot, and AquaTerm on Mac OS X said,

    September 12, 2007 @ 6:28 pm

    [...] official web siteand re-compile it. ./configure make sudo make install Although the author of this articlesaid some modifications are needed, it seems that I’m so luck that I don’t encounter the [...]

  19. stefan said,

    January 7, 2008 @ 11:33 pm

    fink has a gnuplot package!
    install fink, then “fink install gnuplot” - ready.

  20. Teq said,

    February 7, 2008 @ 3:51 pm

    and install FinkCommander for a quick graphical overview of Fink and point-and-click installation ;)

  21. kopinjol said,

    April 28, 2008 @ 12:22 am

    hi,

    Thanks a lot for the instructions. I followed them to the last detail but still got the following error in make :

    “Undefined symbols:
    “_rl_forced_update_display”, referenced from:
    _restore_prompt in command.o
    “_rl_ding”, referenced from:
    _alert in mouse.o
    “_history_list”, referenced from:
    _write_history_list in history.o
    “_rl_complete_with_tilde_expansion”, referenced from:
    _rl_complete_with_tilde_expansion$non_lazy_ptr in plot.o
    “_rl_reset_after_signal”, referenced from:
    _main in plot.o
    ld: symbol(s) not found
    collect2: ld returned 1 exit status”

    I have no idea what may be causing this. So if anyone has a tip, that’ll be great.

    By the way, I didnot have the error message that you predicted on ./prepare.

    thanks,
    kopinjol

  22. Zemogle said,

    May 3, 2008 @ 12:14 am

    I’m getting exactly the same problem as kopinjol. Anyone got any ideas?

  23. Daniel said,

    May 7, 2008 @ 10:55 am

    I have the exact same problem as kopinjol and Zemogle.

  24. Grainger said,

    June 19, 2008 @ 2:03 pm

    The _rl_* errors are caused by OS X 10.5 having a fake readline library which confuses the configure script. Just add: –with-readline=builtin to the configure line and it will solve these issues.

RSS feed for comments on this post · TrackBack URI

Leave a Comment