[Pyrex] problems Linking under Mac OSX

Andreas Kostyrka andreas at mtg.co.at
Thu Oct 9 09:48:25 CEST 2003


On Thu, Oct 09, 2003 at 09:25:17PM +1300, David McNab wrote:
> Hi,
> 
> A python app I'm writing/distributing contains one Pyrex-generated
> module.
> 
> To spare the need for people to install pyrex, I've provided the
> pyrex-generated .c and .h files, plus a makefile which links these.
> 
> For many/most users, this works fine.
> 
> But one Mac OSX user has had no end of trouble.
> 
> Specifically, the module is my SSLCrypto wrapper, which wraps and
> abstracts part of the OpenSSL 'libcrypto' library. For reference,
> there's a tarball of it up on:
> http://www.freenet.org.nz/python/SSLCrypto.
> 
> For most people, the link args '-lcrypto -lpython2.x' suffice. But my
> poor old Mac OSX user is getting hordes of undefined symbols.
> 
> To anyone who's conversant with Mac OSX, can you please tell me:
Ok, I've never seen MacOSX, but I'll try anyway.
> 1) What's the proper way to locate the needed libcrypto.so and
> libpython2.x.so (or equivalent) files on OSX?
Well, you could just distribute a setup.py (distutils), and depending
upon if pyrex is installed, you probably could even make the module
depend upon the pregenerated .c file or upon the .pyx source :)

The key is basically that you have to run the python executable and
wrink the data out of it. Ideas would be sys.prefix, etc.
Distutils basically does that for you :)

> 2) Given my Pyrex-generated file 'SSLCrypto.c', which has compiled ok
> into 'SSLCrypto.o', what gcc options should I use to link it into a
> module that can be imported into Python?
gcc -shared -o SSLCrypto.so SSLCrypto.o # or SSLCrypto.c

Andreas




More information about the Pyrex mailing list