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

36 Comments »

  1. John said

    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

    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

    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. 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. Also, be it known that gnuplot should be compiled with gcc-3.3. Gcc 4 handles objective C differently.

    later,
    andrew.

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

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

    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

    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

    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

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

  14. florian steiner said

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

  15. Patrick Coppock said

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

  16. zorg said

    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

    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. […] 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

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

  20. Teq said

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

  21. kopinjol said

    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

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

  23. Daniel said

    I have the exact same problem as kopinjol and Zemogle.

  24. Grainger said

    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.

  25. arun said

    Thanks a ton! I was struggling with various problems with my gnuplot installation! Various complaints about X11 libraries etc. But it worked fine now.

  26. In my case, X11 was already installed.

    Also there were no such:

    if INCLUDE_BINARY_C
    gnuplot_SOURCES += binary.c
    endif

    lines in my src/Makefile.am, so I only commented out the second group of lines at step 5.

    I also had to add:

    –with-readline=builtin

    to the configure command at step 6.

    Then everything went ok.

    Btw, in my case, the executable installed in /usr/local/bin .

  27. Puzzled said

    😦 Followed all the instructions plus those within the comments, added the -with-readline=builtin (which removed my previous error) but this new one popped up. Running osx 10.5.5 on a macbook pro c2d. Anyone knows whats wrong here? Your help is greatly appreciated!😀

    From terminal:
    ./gnuplot.texi:10582: Cross reference to nonexistent node `origin’ (perhaps incorrect sectioning?).
    ./gnuplot.texi:10076: Cross reference to nonexistent node `origin’ (perhaps incorrect sectioning?).
    ./gnuplot.texi:9734: Cross reference to nonexistent node `origin’ (perhaps incorrect sectioning?).
    ./gnuplot.texi:9513: Cross reference to nonexistent node `origin’ (perhaps incorrect sectioning?).
    ./gnuplot.texi:9502: Cross reference to nonexistent node `origin’ (perhaps incorrect sectioning?).
    ./gnuplot.texi:9493: Cross reference to nonexistent node `origin’ (perhaps incorrect sectioning?).
    ./gnuplot.texi:9476: Cross reference to nonexistent node `origin’ (perhaps incorrect sectioning?).
    ./gnuplot.texi:9474: Cross reference to nonexistent node `origin’ (perhaps incorrect sectioning?).
    ./gnuplot.texi:7413: Cross reference to nonexistent node `origin’ (perhaps incorrect sectioning?).
    ./gnuplot.texi:4870: Cross reference to nonexistent node `origin’ (perhaps incorrect sectioning?).
    ./gnuplot.texi:4851: Cross reference to nonexistent node `origin’ (perhaps incorrect sectioning?).
    ./gnuplot.texi:4840: Cross reference to nonexistent node `origin’ (perhaps incorrect sectioning?).
    ./gnuplot.texi:3459: Cross reference to nonexistent node `origin’ (perhaps incorrect sectioning?).
    ./gnuplot.texi:3131: Cross reference to nonexistent node `origin’ (perhaps incorrect sectioning?).
    makeinfo: Removing output file `gnuplot.info’ due to errors; use –force to preserve.
    make[1]: *** [gnuplot.info] Error 1
    make: *** [install-recursive] Error 1

  28. Raymond said

    Hi Puzzled,

    I found the fix for your problem here:

    http://article.gmane.org/gmane.comp.graphics.gnuplot.devel/7544

    The keyword “origin” has been replaced in some places by “origin_”, but the fix is easy: in the source directory, use the following sed command, and run make again:

    $ sed -i ‘s/origin_/origin/g’ docs/gnuplot.texi

    That fixed it for me.

  29. Michael L said

    If you have macPorts installed, you can just type:

    sudo port install gnuplot

    http://gavmacprogramming.wordpress.com/2007/05/02/installing-gnuplot/

  30. Eric said

    Not working…

    I have a MacBook Pro Intel Core 2 Duo running OS X 10.5.6. At first, I had the same problem as Kopinjol (with the _rl_* errors). I did the –with-readline=builtin thing and it fixed that part. When I did the make, I got:

    make
    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.3\” -DGNUPLOT_PS_DIR=\”/usr/local/share/gnuplot/4.3/PostScript\” -DCONTACT=\”gnuplot-bugs@lists.sourceforge.net\” -DHELPFILE=\”/usr/local/share/gnuplot/4.3/gnuplot.gih\” -DGNUPLOT_X11=\”`echo gnuplot_x11 | sed ‘s,x,x,’`\” -g -O2 -ObjC -MT alloc.o -MD -MP -MF .deps/alloc.Tpo -c -o alloc.o alloc.c
    mv -f .deps/alloc.Tpo .deps/alloc.Po
    ….

    In file included from term.h:173,
    from term.c:1368:
    ../term/aquaterm.trm: In function ‘AQUA_boxfill’:
    ../term/aquaterm.trm:586: warning: ‘AQTAdapter’ may not respond to ‘-setColorRed:green:blue:alpha:’
    ../term/aquaterm.trm:586: warning: (Messages without a matching method signature
    ../term/aquaterm.trm:586: warning: will be assumed to return ‘id’ and accept
    ../term/aquaterm.trm:586: warning: ‘…’ as arguments.)
    ../term/aquaterm.trm: In function ‘AQUA_filled_polygon’:
    ../term/aquaterm.trm:683: warning: ‘AQTAdapter’ may not respond to ‘-setColorRed:green:blue:alpha:’
    mv -f .deps/term.Tpo .deps/term.Po
    gcc -DHAVE_CONFIG_H -I. -I.. -I../term -I../term -DBINDIR=\”/usr/local/bin\” -DX11_DRIVER_DIR=\”/usr/local/libexec/gnuplot/4.3\” -DGNUPLOT_PS_DIR=\”/usr/local/share/gnuplot/4.3/PostScript\” -DCONTACT=\”gnuplot-bugs@lists.sourceforge.net\” -DHELPFILE=\”/usr/local/share/gnuplot/4.3/gnuplot.gih\” -DGNUPLOT_X11=\”`echo gnuplot_x11 | sed ‘s,x,x,’`\” -g -O2 -ObjC -MT time.o -MD -MP -MF .deps/time.Tpo -c -o time.o time.c
    mv -f .deps/time.Tpo .deps/time.Po
    ….
    ….
    gcc -g -O2 -ObjC -o bf_test bf_test.o binary.o alloc.o -laquaterm -framework Foundation
    Making all in docs
    gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I../src -I../term -g -O2 -ObjC -c doc2gih.c
    gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I../src -I../term -g -O2 -ObjC -c termdoc.c
    gcc -g -O2 -ObjC -o doc2gih doc2gih.o termdoc.o -laquaterm -framework Foundation
    ./doc2gih ./gnuplot.doc gnuplot.gih
    Making all in lisp
    make[2]: Nothing to be done for `all’.
    Making all in man
    make[2]: Nothing to be done for `all’.
    Making all in demo
    Creating binary data files
    Making all in tutorial
    make[2]: Nothing to be done for `all’.
    Making all in share
    Making all in LaTeX
    make[3]: Nothing to be done for `all’.
    make[3]: Nothing to be done for `all-am’.
    make[2]: Nothing to be done for `all-am’.

    And I got the following when I did make install, I got:

    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.3/PostScript” || .././install-sh -c -d “/usr/local/share/gnuplot/4.3/PostScript”
    /usr/bin/install -c -m 644 ‘PostScript/cp1250.ps’ ‘/usr/local/share/gnuplot/4.3/PostScript/cp1250.ps’
    /usr/bin/install -c -m 644 ‘PostScript/cp437.ps’ ‘/usr/local/share/gnuplot/4.3/PostScript/cp437.ps’
    ….

    /usr/bin/install -c -m 644 gnuplot.elc /usr/local/share/emacs/site-lisp/gnuplot.elc
    /usr/bin/install -c -m 644 gnuplot-gui.elc /usr/local/share/emacs/site-lisp/gnuplot-gui.elc
    Making install in man
    make[2]: Nothing to be done for `install-exec-am’.
    test -z “/usr/local/share/man/man1” || .././install-sh -c -d “/usr/local/share/man/man1”
    /usr/bin/install -c -m 644 ‘./gnuplot.1’ ‘/usr/local/share/man/man1/gnuplot.1′
    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’.
    make install-data-hook
    make[3]: Nothing to be done for `install-exec-am’.
    test -z “/usr/local/lib/X11/app-defaults” || .././install-sh -c -d “/usr/local/lib/X11/app-defaults”
    /usr/bin/install -c -m 644 ‘Gnuplot’ ‘/usr/local/lib/X11/app-defaults/Gnuplot’
    make[2]: Nothing to be done for `install-exec-am’.
    make[2]: Nothing to be done for `install-data-am’.

    and then when I try to start gnuplot, it says the good old “command not found”…. What to do? Help! Thanks a lot in advance

  31. TonyMac said

    @grainger:
    next to the pb of kopinjol and Zemogle: the option –with-readline=builtin effectively solves the missing of the readline. but the gnuplot will be installed without the autocompletion features (TAB key gives nothing as completion and so on). THerefore the –with-readline=gnu will give error when compiling sources. THe solution is to install GNU readline that u can find at:
    http://tiswww.case.edu/php/chet/readline/rltop.html
    which is really simple to install (./configure // make // sudo make install ) n u are done.
    After installed GNU readline u can use the make issu from the configure –with-readline=gnu

  32. Miguel said

    Octave distributes updated binaries of gnuplot for Mac OS X.

    http://sourceforge.net/projects/octave/files/Octave%20MacOSX%20Binary
    http://octave.sourceforge.net/

  33. Peggy Li said

    Hi

    I have downloaded gnuplot-4.4.0 for my MacBook Pro. I have untar(ed) it and pulled it to my Desktop. I followed your webpage to install it. Firstly, I go to the gnuplot-4.4.0 directory (i.e., cd gnuplot-4.4.0) and then typed ./prepare (to yield the “configure” script. However, I received the error message “No such file or directory”. Please advise what should I do. Do I need to pull the folder “gnuplot-4.4.0” to the “application folder”. Or Where should I put the “gnuplot-4.4.0” folder? Hope that you could help!

    Peggy Li

  34. Peggy Li said

    Further to my earlier comment. My MacBook Pro has X11 installed.

    Peggy Li

    • TonyMac said

      @Li: I didn’t understand your command ./prepare, have u simply to try ./configure and follow those steps as described in the README & INSTALL text file

  35. Ram Adhikari said

    awesome post… worked like a charm🙂.
    Thanks a ton.

RSS feed for comments on this post · TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: