Showing posts with label homebrew. Show all posts
Showing posts with label homebrew. Show all posts

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.

Tuesday, October 18, 2011

ddd on Snow Leopard


I want to use ddd on my macbook pro with Snow Leopard, but it was not an easy task. The most annoying problem was the error related with the 'Ddd defaults application' file:

Error: No `Ddd' application defaults file
To resolve this problem, you can:
* set the XAPPLRESDIR environment variable to the location of the file
`Ddd', or
* set the DDD_HOME environment variable to the location of `ddd/Ddd', or
* install the `Ddd' file in the X application defaults directory, or
* recompile DDD with builtin app-defaults file;
see the `--enable-builtin-app-defaults' option for details.

Even after following each one of this suggestions, ddd still did not work. For example, when I tried to compile by using the flag --enable-builtin-app-defaults , the compilation ended with an error after many lines of cryptic messages. At the end, I discovered that it was much better to recompile using a different extension for the executable, like make EXEEXT=exe .

Fortunately, I am using the amazing package manager homebrew , which a great replacing option for the mess of both macports and/or fink.

To install ddd, I just use :
brew install ddd
The formula for ddd includes fixes for the 'defaults file' problem.

But, of course, this is not the end. After installing with brew, ddd still does not work. It gives a seg fault. The problem is related with the X11 libraries (there are at least 3 different directories with X11 libraries!). I would like to tell brew to use some specific x-includes, but I was not not able to find a way to do that without editing the formula, which was what I did at the end. I just wrote

brew edit ddd

and I added

, "--x-includes=/Developer/SDKs/MacOSX10.6.sdk/usr/X11/include", "--x-libraries=/Developer/SDKs/MacOSX10.6.sdk/usr/X11/lib"

to the configure line. It now looks like:

def install
system "./configure", "--disable-debug", "--disable-dependency-tracking",
"--enable-builtin-app-defaults", "--enable-builtin-manual",
"--prefix=#{prefix}", "--x-includes=/Developer/SDKs/MacOSX10.6.sdk/usr/X11/include", "--x-libraries=/Developer/SDKs/MacOSX10.6.sdk/usr/X11/lib"

It is horrible, but it works. After that, I was able to compile again and succesfully use ddd on the mac. I am not sure if this modification to the formula is the best way to proceed, but at least if worked. If you have any suggestion, please fell free to make it. (I hope somebody reads this entry sometime in the close future :) )