[Pythonmac-SIG] Using distutils with XCode

Paul Kinnane pkinnane at internode.on.net
Mon Oct 3 12:05:29 CEST 2005


OK, I found I could compile and successfully import the test.c sample
from http://www.nevada.edu/~cwebster/Python/MPWHOWTO/MPWHOWTO.html using
the Darwin "python setup.py install" command.

However, I'm trying to compile a wrapper for the ode physics engine.
The wrapper is call PyODE (http://pyode.sourceforge.net/) and I've
successfully compiled it on the Windows platform and been able to import
it into python.

Using "python setup.py install", I get a permissions error.  I assume
there is a simply way for me to get the right access rights in Darwin to
do an install?  Anyway, doing a build and then manual install gives the
following error when trying to import into Python...

ImportError:Failure linking new module: ode.so: Symbol not found:
___cxa_pure_virtual
Reference from:ode.so
Expected in:Flat namespace

A search of the web revealed I could define the __cxa_pure_virtual
function in the link parameters in setup.py, however that led to a
"fragment" error when trying to import.  Researching the web there was a
lot of info about using g++ instead of gcc for linking etc, which coming
from the Win platform was a little confusing.

Some questions....

1) Is there any difference between compiling the extern library wrapper
in gcc verses XCode?
2) If I can use gcc, should I only use gcc3.2?  (as recommended in some
msg threads)
3) Is defining ___cxa_pure_virtual in the link statement the correct way
to resolve that problem?  If so, what is the exact cmd line parameter I
should use to do this?

Thanks for any assistance given.

Paul

-----Original Message-----
From: Chris Barker [mailto:Chris.Barker at noaa.gov] 
Sent: Saturday, 1 October 2005 1:38 AM
To: Paul Kinnane; pythonmac-sig at python.org
Subject: Re: [Pythonmac-SIG] Using distutils with XCode

Paul Kinnane wrote:
> the distutils on OSX10.4.  I don't have CodeWarrior 7 and wondered if
it
> was possible to manually compile the library using XCode?  I see it is
> possible using MPW
> (http://www.nevada.edu/~cwebster/Python/MPWHOWTO/MPWHOWTO.html) -

that is a very old doc, and only applies to OS-9 and below.

On OS-X, the standard way to compile python is with Apple's gcc. 
provided with the XCode package.

you should be able to do a simple:

python setup.py build

at the command line, if you want to use the Apple-provided python. If 
you've installed python2.4.1, then do:

python2.4 setup.py build

or

/usr/local/python setup.py build

depending on how your PATH is set.

If this doesn't work, post your errors, and we'll see what we can 
suggest. If the code works with gcc on other systems (Cygwin, Linux, 
etc), then there is a good chance it will work on OS-X. If it's only 
been compiled with MS compiler, it may need some tweaking.

-Chris


-- 
Christopher Barker, Ph.D.
Oceanographer
                                     		
NOAA/OR&R/HAZMAT         (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov



More information about the Pythonmac-SIG mailing list