Building gnuplot on OS X

As part of my on-going efforts to get my new MacBook Pro set up with my normal working environment, I tried to compile gnuplot. The first problem was that libpng and libgd were not installed so there was no png support. In short order, I downloaded the libraries and got them compiled. On to building gnuplot.

The problem was that the configure script for gnuplot could not verify that libgd was installed even though it was. I tried all sorts configure arguments and other machinations but no joy.

I asked DuckDuckGo and it said that everyone was having the same problem but none of the suggested solutions worked. Finally, I gave up and just modified to configure script to believe that it had found it. configure scripts are notoriously opaque and very hard to figure out. After a bit of fussing around, I got it to believe that libgd really was there. After that, gnuplot compiled with png support and works perfectly.

I think this is probably some artifact of Apple using LLVM instead of gcc. If you’re trying to build gnuport on a recent version of OS X and having problems with libgd support, here’s a patch for configure that worked for me.

--- configure.orig      2014-10-19 08:18:04.000000000 -0400
+++ configure   2014-10-19 08:46:47.000000000 -0400
@@ -10266,7 +10266,9 @@
 else
          { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libgd not found or too old, version >= 2.0 is required" >&5
 $as_echo "$as_me: WARNING: libgd not found or too old, version >= 2.0 is required" >&2;}
-       with_gd=no
+       with_gd=yes
+$as_echo "#define HAVE_GD_PNG 1" >>confdefs.h
+libgd_LIBS="$libgd_LIBS -lpng"

 fi

@@ -15456,7 +15458,8 @@
 fi


-if test "$ac_cv_lib_gd_gdImagePng" = yes; then
+#if test "$ac_cv_lib_gd_gdImagePng" = yes; then
+if true; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result:   png terminal: yes" >&5
 $as_echo "  png terminal: yes" >&6; }
 else

This is probably not an optimal patch since I was flailing around trying to get it to work but it is, after all, just to get configure to agree that libgd is there. Just make sure that libgd really is installed.

This entry was posted in General and tagged , . Bookmark the permalink.