Python extension on Windows
Gerhard Häring
gh at ghaering.de
Fri Jul 11 11:16:08 EDT 2003
David Isal wrote:
> hi all,
> i'm new to python and i'm trying to build a python extension on win98,
> written in c++, with cygwin.^
So we're talking native win32 here, right? You *can* use the Cygwin
toolset to compile native win32 executables and DLLs, but I prefer to
use MINGW for this.
> but i keep having the same error message, and i didnt't find much
> resources on the web about it:
> >g++ -I/cygdrive/c/python22/include -c demomodule.cpp -o demomodule.o
>
> In file included from /cygdrive/c/python22/include/Python.h:62,
> from demomodule.cpp:1:
> /cygdrive/c/python22/include/pyport.h:480:2: #error "LONG_BIT definition
> appears wrong for platform (bad gcc/glibc config?)."
Yep. Use MINGW, the native GCC for win32. That's what I use and where I
could help you with.
If you want to continue using Cygwin to build extension modules, be sure
to have the win32api Cygwin package installed.
> i read that it is mandatory to use Micro$oft visual c++ to build any
> extensions on windows beacuse it's the same compiler used to build
> python for windows.
That's wrong. See
http://www.python.org/doc/current/inst/non-ms-compilers.html
> does anybody has advices about that?
Yes, read the above page :-)
I also recommend to use distutils to compile Python extensions instead
of trying to find out the correct compiler and linker options yourself.
It's the easiest way to compile Python extensions, no matter what the
platform.
See http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66509 for a
recipe.
Build it using mingw or Cygwin with this command:
c:/python22/python setup.py build --compiler=mingw32
I'd recommend you try a minimal C extension first before using C++. IIRC
I needed to use something like libraries=["stdc++"] for making a C++
extension with distutils.
-- Gerhard
More information about the Python-list
mailing list