A
Andrew Gregory
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 = "(e-mail address removed)",
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.
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 = "(e-mail address removed)",
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.