Distutils and MinGW with C++

Andrew Gregory andrew.gregory at npl.co.uk
Tue Dec 10 06:54:08 EST 2002


If I wrap (SWIG) and compile (Mingw 2.0.0, gcc 3.2) a simple program
as C code to produce a Python DLL everything works ok (using distutils
and Python 2.2.2)

But if compile as C++ I get an error message at the dllwrap stage:

undefined reference to '__gxx_personality_v0'
dllwrap exited with status 1

For more complicated programs occurrences of new and delete in the
wrapper produce "not found" errors.

I noticed that distutils compiles with gcc (not g++).

I changed the wrapper extension from .cxx to .cpp - but this did not
help.


//Test function (pysmimple.h) is

extern int mysquare(int i)
{
  return i*i;
};


Used: 
SWIG -c++ -python pysimple.i to make wrapper pysimple_wrap.cxx
python setup.py build --compiler=mingw32

setup.py looks like

from distutils.core import setup, Extension
setup (name = "_pysimple",
       version = "1.0",
       maintainer = "Andrew Gregory",
       maintainer_email = "andrew.gregory at npl.co.uk",
       description = "Sample Python C++ DLL",
       ext_modules =
[Extension('_pysimple',sources=['pysimple_wrap.cxx'])])


Any help would be appreciated.



More information about the Python-list mailing list