470,810 Members | 1,251 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,810 developers. It's quick & easy.

Python extension on Windows

hi all,
i'm new to python and i'm trying to build a python extension on win98,
written in c++, with cygwin.
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?)."

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.
does anybody has advices about that?
i would rather use cygwin/g++ but i don't know if it's possible or how
to fix this error message.
thanks in advance,
David.

Jul 18 '05 #1
3 4375
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/in...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/Coo...n/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

Jul 18 '05 #2
David Isal <da********@wanadoo.fr> wrote in message news:<be**********@news-reader4.wanadoo.fr>...
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.
does anybody has advices about that?
i would rather use cygwin/g++ but i don't know if it's possible or how
to fix this error message.


I don't know what's causing your particular problem (since I got free
MSVC++ from a Microsoft promotional gimmick), but if you download the
python 2.2.3 source and compile that with Cygwin, that should
eliminate any possible incompatibilities between compilers.

The source tarball is at
<http://python.org/ftp/python/2.2.3/Python-2.2.3.tgz>.
Jul 18 '05 #3
thank you guys for your advices ;-)
Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by BOOGIEMAN | last post: by
3 posts views Thread by Matthias Baas | last post: by
10 posts views Thread by Andrew Dalke | last post: by
6 posts views Thread by JW | last post: by
32 posts views Thread by siggi | last post: by
15 posts views Thread by kyosohma | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.