[Pythonmac-SIG] Using SWIG, C++, and OS X
Ronald Oussoren
ronaldoussoren at mac.com
Thu Jul 6 21:16:09 CEST 2006
On Jul 6, 2006, at 7:58 PM, Siddartha Krishnan wrote:
> Hi,
>
> I'm new to using SWIG for python. I am having several problems
> creating a C++ extension module for python. I am using OS X 10.4 with
> python 2.4 and SWIG 1.3.29 (using darwinports).
>
> I can use SWIG and distutils in order to make a C extension module
> for python, however, I cannot do so for a C++ extension module - I
> get an import error:
>
> mie-15-203:~/swig/class_test siddarthakrishnan$ python mymod.py
> Traceback (most recent call last):
> File "mymod.py", line 5, in ?
> import _mymod
> ImportError: Failure linking new module: /Users/siddarthakrishnan/
> SWIG/class_test/_mymod.so: Symbol not found: __ZN9SomeClassC1Eii
> Referenced from: /Users/siddarthakrishnan/SWIG/class_test/_mymod.so
> Expected in: dynamic lookup
>
> The setup.py file is as follows:
>
> # setup.py
> from distutils.core import setup, Extension
> setup (name = "_mymod",
> version = "1.0",
> maintainer = "Your Name",
> maintainer_email = "your.name at domain.org",
> description = "Sample Python C++ Extension",
> ext_modules = [Extension('_mymod',
> sources=['mymod_wrap.cxx'])])
>
> Does anyone know how to create a setup.py file that works with c++
> extension modules?
Are you linking with all libraries that are needed for the extension?
Your module seems to be missing 'SomeClass::SomeClass(int, int)'.
If you do the link step that setup.py generates manually, but add '-
framework Python' and remove '-undefined surpress' you should get a
list of all symbols that aren't present in the extension. However,
don't build the final version of the extension like that.
Ronald
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2157 bytes
Desc: not available
Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20060706/e9022998/attachment.bin
More information about the Pythonmac-SIG
mailing list