[Pythonmac-SIG] CPython on Mac OSX

Bob Ippolito bob at redivi.com
Thu Dec 14 11:28:29 CET 2006

On 12/13/06, Gen Kazama <generalkernel at gmail.com> wrote:
> Hi I'm running python 2.3 on 10.4.  i made an application using a C backend
> and a python frontend.
> This is a school project and although it works perfectly on the school
> computers, i have trouble compiling the C code correctly on the mac to make
> it into a python module (maybe this is because the school computers used
> python 2.4-ie, an updated version of Python.h).
> Anyway here is how I compile it at school:
>         gcc -I /usr/include/python2.4 -c mandel.c
>         gcc -shared mandel.o -o mandel.so
> which works with no flaws.  then , I try compiling it on my mac:
>         gcc -I /usr/include/python2.3 -c mandel.c
>         gcc mandel.o -o mandel.so
> (note: -shared wasn't found on my mac for some reason). I get the following
> errors:
> /usr/bin/ld: Undefined symbols:
> _main
> _PyArg_ParseTuple
> _PyInt_FromLong
> _PyString_FromString
> _PyTuple_New
> _PyTuple_SetItem
> _Py_InitModule4
> collect2: ld returned 1 exit status
> If anyone could tell me how to compile this C code into a python module on
> my mac, i would greatly appreciate it.  thanks!

The best way is to use distutils (or setuptools). Create a setup.py
that compiles it for you. This works on every platform, even windows.


More information about the Pythonmac-SIG mailing list