By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,156 Members | 962 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,156 IT Pros & Developers. It's quick & easy.

Python 2.3 distutils with Mingw C++

P: n/a
In Python 2.2, I compiled some C++ code on Windows (MinGW compiler) to
create an extension using distutils and the following setup.py file:

from distutils.core import setup, Extension
setup (name = "_pysimple",
version = "1.0",
maintainer = "AG",
maintainer_email = "xx*@xx.co.uk",
description = "Sample Python C++ DLL",
ext_modules = [Extension('_pysimple',

extra_compile_args=['-O2','-march=i586','-malign-double'],
extra_link_args=['-mthread'],
library_dirs=['C:\\mingw\\lib'],
libraries=['supc++'], # if using iostreams etc.
use stdc++
sources=['pysimple_wrap.cxx'])])

Provided that certain C++ features such as templates were not used,
this would build ok using the gcc compiler (not g++), as supc++ is
linked to.
Command used is: python setup.py build --compiler=mingw32

In Python 2.3, distutils recognises the .cxx extension as C++ and
tries to compile with
cc -mno-cygwin -shared etc.
resulting in "cc not found" error message. It should compile with
c:\mingw\bin\gcc -mno-cygwin -shared etc.
or *much* better
c:\mingw\bin\g++ -mno-cygwin -shared etc.

The quick fix is to copy the old distutils subdirectory from Python22
into Python23.

Andrew.
Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.