[Pyrex] problems Linking under Mac OSX

Greg Ewing greg at cosc.canterbury.ac.nz
Fri Oct 10 01:27:42 CEST 2003


David McNab <david at rebirthing.co.nz>:

> To anyone who's conversant with Mac OSX, can you please tell me:
> 1) What's the proper way to locate the needed libcrypto.so and
> libpython2.x.so (or equivalent) files on OSX?

On the MacOSX 10.1 system I have beside me at the moment,
there's a libcrypto.dylib in /usr/lib, so I don't see why
-lcrypto shouldn't work for that (and a brief experiment
confirms that it does).

As for Python, it will depend on whether it was compiled
and installed in the traditional Unix fashion, or whether
it was installed as a framework. If the latter, you will
need

  -framework Python

That should be enough if the framework is in one of the
standard locations, such as /Library/Frameworks.

> 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?

To create an extension module, you will also need

  -bundle

e.g.

  cc -bundle -framework Python mymodule.o -o mymodule.so

At least I think that's all you need, but I may have
forgotten some vital thing.

But the best way to compile extension modules is probably to use
distutils, which knows all the tricky details of how to do it right
for your particular system and installation.  I'd recommend writing a
setup.py for your module. You can invoke it from the makefile if you
want people to be able to use make.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+




More information about the Pyrex mailing list