Python extension on Windows

D

David Isal

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.
 
?

=?ISO-8859-1?Q?Gerhard_H=E4ring?=

David said:
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:

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
 
P

Peter Scott

David Isal said:
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>.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top