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 = "[EMAIL PROTECTED]",
        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?

Also, I tried to compile a shared library manually, using:
ld -L/opt/local/lib -bundle -undefined suppress -flat_namespace -o  
testmod.so testmod_wrap.o testmod.o

However, when I try to import the module, I get the following error:
 >>> import testmod
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
ImportError: Failure linking new module: testmod.so: Symbol not  
found: dyld_stub_binding_helper
   Referenced from: testmod.so
   Expected in: flat namespace

This is for both C and C++ extension modules.

Can someone please help solve this problem?

Thanks,

Siddartha
  
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to