It didn't work. But I may have misunderstood your instructions.
Here's the output from compiling matplotlib:

Here's what I did.
Set export CC=gcc-4.2

Downloaded and compiled libpng-1.4.3
Downloaded and compiled libfreetype-2.3.12
Downloaded matplotlib-0.99.3
Modified src/_png.cpp in matplotlib
Replaced with your version.
sudo python build
sudo python install

Any obvious mistakes?

Thanks again for your help,


On Mon, Jun 28, 2010 at 1:05 PM, Friedrich Romstedt <> wrote:
2010/6/28 Ranjit Chacko <>:
> I just tried compiling with the following command:
> sudo make -f make.osx fetch deps mpl_build mpl_install

I don't know, I saw now so many people running into trouble with
make.osx, would you, as a test case, please apply the following steps
to your installation:

First, I see that the freetype is linked in statically, but still it
cannot be loaded on startup time (this _something_foobar symbol seems
the first one it attemts to load).  I remember that make.osx is
intended for binary distributable generation, and therefore it links

I want to propose a different solution here.

Would you please modify first your matplotlib in the
following way.  We'll attemt a build without make.osx and fetch etc.,
but a real distutil build with dynamic linking :-) !:

On the line with 'darwin' : [], add:

   'darwin' : ['/usr/local'],

and maybe also '/usr/X11/lib' or '/usr/X11' and let the /lib suffix
alone, but I think as you installed pkg-config, it could maybe work
also out of the box.  For me, I were not aware of pkg-config for OS X,
so I still don't have it :-).  If you are not sure, simply try to run
pkg-config in the console, by tab expansion, if it finds it, it's

I also attach the modified files for your convenience, but you should
use diff because I built that time, and something may have
changed by that.

Then, please compile (if you did not already do that), libpng 1.4 (not
1.2!) and libfreetype2 from the official sources.  Always use the
following environment variables:

export CC=gcc-4.2
(To not use 4.0 occasionally)
(To avoid certain warnings which are quite annoying during build.  If
you attemt to use py2app for deployment on 10.3 or 10.4 you should
modify of course.)

It is important that you compile *all* your software which is
incorporated with the same variables.  Well, at least I by accident
one time set _TARGET to another value after ./configure, and it
refused to compile then.  So, feel free to experiment, but please
document properly and, most important, tell us the results!  I'm still
in the ascending branch of my OS X learning curve.

Maybe now it's the right moment to compile Python (1.6.5, I think not
1.7) and then numpy again with this settings.  For Python, use

./configure --enable-framework

Then compile libfreetype2.  Compile libpng 1.4 or whatever.

Now it's time to compile matplotlib itself.  Just use the usual flags,
and, for me, it worked like a charm.  But one modification has to be
made: matplotlib isn't compatible with libpng 1.4 from the beginning,
please add the following lines to src/_png.cpp:

#define png_infopp_NULL (png_infopp)NULL
#define int_p_NULL (int*)NULL

Somewhere before the actual code, it doesn't matter where, but after
the #include <png.cpp> of course.  I also attach the file, same
applies, run diff before.  It's my obligation to provide a proper
matplotlib patch for this issue, but for now please patch by hand.

There are several reasons why to compile Python yourself: It will use
the new Tcl/Tk, which is much more beautiful than the old one.  It
will compile with the compatible flags.  Well that's it I think.  If
you intend to use PIL btw, you have to compile Python yourself.

Now you should be done.  If you run into some problems, please tell us.