Symbol not found

I just tried compiling with the following command:
sudo make -f make.osx fetch deps mpl_build mpl_install

At first it was failing almost immediately, but then I changed make.osx so that it was fetching zlib-1.2.5 and it got further but still failed. The log is at the link below:

http://pastebin.org/363644

···

On Mon, Jun 28, 2010 at 9:36 AM, Ranjit Chacko <rjchacko@…120…287…> wrote:

I edited the make.osx file also which you can see here:
http://titanpad.com/94eSOCozk4

On Mon, Jun 28, 2010 at 9:19 AM, Ranjit Chacko <rjchacko@…287…> wrote:

Thanks so much for your help. I really appreciate it.

This is what I get when I run otool:

ft2font.so (architecture ppc7400):
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)

/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.11)
/usr/local/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libmx.A.dylib (compatibility version 1.0.0, current version 47.1.0)

ft2font.so (architecture i386):
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.11)

/usr/local/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)

This is the output of gcc --version:
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)

And the output of g++:

i686-apple-darwin10-g+±4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)

I’m not really sure what the steps I followed are anymore. After things didn’t work I just tried different things I saw described on different blogs or mailing list archives.

I’m not sure if I used pkg-config though. I’m trying to compile matplotlib on 10.6. At first nothing was working, and then I downloaded Xcode again and checked off the option to include the 10.4 libraries, so both are present now. Both gcc-.40 and gcc-4.2 are present but I’m not really sure what’s being used when.

Thanks again.

-Ranjit

On Sun, Jun 27, 2010 at 2:22 PM, Friedrich Romstedt <friedrichromstedt@…287…> wrote:

First, since you said you used pkg-config I would like to know what

libfreetype the ft2font.so lib is actually linked against. Can you

issue an otool -L ft2font.so in the matplotlib’s directory? This will

tell you what libs are used.

I think most important is the compiler used, but since you are on 10.4

apparently, I don’t know what the recent compiler for you is. Is it

gcc-4.0? (It seems to be.) Are there other gcc’s around which could

have been used for the libfreetype2, or for Python itself? Can you

issue in a clean shell gcc --version, and it seems you used c++ as the

command for .cpp sources, right, so can you issue c++ --version too?

And what were your steps to get it build from the weird errors you

posted before (I didn’t get a clue from them).

I don’t know if I can help you but at least I can try to, right …

Friedrich

2010/6/25 Ranjit Chacko <rjchacko@…287…>:

I finally somehow managed to get matplotlib to compile but now when I try to

import matplotlib.pyplot I get the following error:

ImportError:

dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/ft2font.so,

2): Symbol not found: _FT_Attach_File

Referenced from:

/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/ft2font.so

Expected in: dynamic lookup

2010/6/28 Ranjit Chacko <rjchacko@...287...>:

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

I want to propose a different solution here.

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

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

I also attach the modified files for your convenience, but you should
use diff because I built that time 0.99.1.2, 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)
export MACOSX_DEPLOYMENT_TARGET=10.5
(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.

Friedrich

setupext.py (46.3 KB)

_png.cpp (9.67 KB)

It didn’t work. But I may have misunderstood your instructions.
Here’s the output from compiling matplotlib:
http://pastebin.org/363870

Here’s what I did.
Set export CC=gcc-4.2
Set export MACOSX_DEPLOYMENT_TARGET=10.5

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 setupext.py with your version.
sudo python setup.py build
sudo python setup.py install

Any obvious mistakes?

Thanks again for your help,

-Ranjit

···

On Mon, Jun 28, 2010 at 1:05 PM, Friedrich Romstedt <friedrichromstedt@…287…> wrote:

2010/6/28 Ranjit Chacko <rjchacko@…287…>:

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

statically.

I want to propose a different solution here.

Would you please modify first your matplotlib setupext.py in the

following way. We’ll attemt a build without make.osx and fetch etc.,

but a real distutil build with dynamic linking :slight_smile: !:

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

installed.

I also attach the modified files for your convenience, but you should

use diff because I built that time 0.99.1.2, 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)

export MACOSX_DEPLOYMENT_TARGET=10.5

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

Friedrich