Wednesday, April 11, 2012

xmgrace and png lib on Snow Leopard 10.6.8

I am using xmgrace a lot for plotting. Although I still like gnuplot, and its 3D utilities are beyond those of xmgrace (which is only 2D), I find xmgrace usefull for storing all the graph info into one single file. Yes, I know, I can save the gnuplot commands, and then rebuild the graph with the original data, etc, but xmgrace just contains everuthing in a single file.

I am currently printing to both pdf and jpeg formats from xmgrace, since png support was broken. But I need png support. After some digging into the system, I found that Snow Leopard has several versions for libpng and its include files, changing the lib/inc version number. At the end, I foudn the following solution to the configure script whichs sets everything up:

./configure LDFLAGS="-L/opt/X11/lib" CPPFLAGS="-I/opt/X11/include/libpng15" --with-png-library=-lpng15

This means I am using the png library installed from XQuartz. BTW, if you are using homebrew as me, just edit the grace formula to add the flags shown above:

  def install
    #ENV.x11
    ENV.append "LDFLAGS", "-L/opt/X11/lib"
    ENV.append "CPPFLAGS", "-I/opt/X11/include/libpng15"
    system "./configure", "--disable-debug", "--disable-dependency-tracking",
      "--prefix=#{prefix}", "--with-zlib",
      "--with-png-library=-lpng15",
      "--enable-grace-home=#{prefix}"

    system "make install"
  end


If you have gfortran, do not have f77, and you want the fortran tests, make a symbolic link from gfrotran to f77.