[Distutils] Compiling Python C++ extensions with MingW

Andrew Gregory Andrew.Gregory@npl.co.uk
Sat Dec 14 12:23:02 2002


Apologies for troubling you all, the solution is quite simple. You just
need to include library stdc++. I'll post something on the newsgroup.
The setup.py file looks like:

# setup.py - for building _pysimple.pyd
#
# To use, from command line type:
#   python setup.py build --compiler=mingw32
# #   or python setup.py build --compiler=bcpp
#
# If sources=['pysimple.i'] then SWIG will be called
# but do not yet know how to set SWIG options.
#
from distutils.core import setup, Extension
setup (name = "_pysimple",
       version = "1.0",
       maintainer = "Andrew Gregory",
       maintainer_email = "andrew.gregory@npl.co.uk",
       description = "Sample Python DLL",
       ext_modules = [Extension('_pysimple',
                      library_dirs=['C:\\mingw\\lib'],
                      libraries=['stdc++'],
                      sources=['pysimple_wrap.cxx'])])

Suggestion:
   a future release of distutils might do this automatically for mingw
when the source extension is .cpp, .cc or .cxx?


Andrew Gregory.


> -----Original Message-----
> From: David Abrahams [mailto:dave@boost-consulting.com]
> Sent: 11 December 2002 21:50
> To: M.-A. Lemburg
> Cc: Andrew Gregory; 'distutils-sig@python.org'
> Subject: Re: [Distutils] Compiling Python C++ extensions with MingW
> 
> 
> "M.-A. Lemburg" <mal@lemburg.com> writes:
> 
> > David Abrahams wrote:
> >> "M.-A. Lemburg" <mal@lemburg.com> writes:
> >>
> >>>>ap.cxx: undefined reference to `__gxx_personalit
> >>>>y_v0'
> >>>>dllwrap: gcc exited with status 1
> >>>>error: command 'dllwrap' failed with exit status 1
> >>>
> >>>Looks like some lib is missing. Hard to tell which without
> >>>a working MinGW installed :-)
> >> That's not just "some lib", but a part of the C++ runtime. 
> It may be
> >> as simple as setting LD_LIBRARY_PATH to include the location of the
> >> C++ runtimes shipped with mingw when linking.
> >
> > Patches are welcome. AFAIK, nobody is supporting MinGW for 
> distutils,
> > so you're on your own here.
> >
> > Could be that g++ needs to be used instead of gcc for compiling
> > C++ code... 
> 
> Yes, that is definitely the case.
> 
> > at least that's what the CVS log suggests. The MinGW class has gcc
> > hard-coded...
> 
> Easy fix, then!
> 
> -- 
>                        David Abrahams
>    dave@boost-consulting.com * http://www.boost-consulting.com
> Boost support, enhancements, training, and commercial distribution
> 

-------------------------------------------------------------------
This e-mail and any attachments may contain confidential and/or
privileged material; it is for the intended addressee(s) only.
If you are not a named addressee, you must not use, retain or
disclose such information.

NPL Management Ltd cannot guarantee that the e-mail or any
attachments are free from viruses.

NPL Management Ltd. Registered in England and Wales. No: 2937881
Registered Office: Teddington, Middlesex, United Kingdom TW11 0LW.
-------------------------------------------------------------------