Python extension on Windows

Discussion in 'Python' started by David Isal, Jul 11, 2003.

  1. David Isal

    David Isal Guest

    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.
    David Isal, Jul 11, 2003
    #1
    1. Advertising

  2. 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
    =?ISO-8859-1?Q?Gerhard_H=E4ring?=, Jul 11, 2003
    #2
    1. Advertising

  3. David Isal

    Peter Scott Guest

    David Isal <> wrote in message news:<bemf6t$l1r$>...
    > 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>.
    Peter Scott, Jul 11, 2003
    #3
  4. David Isal

    David Isal Guest

    thank you guys for your advices ;-)
    David Isal, Jul 12, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anand
    Replies:
    3
    Views:
    878
    Tim Daneliuk
    Nov 8, 2003
  2. Christian Seberino
    Replies:
    3
    Views:
    1,168
    Christian Seberino
    Feb 5, 2004
  3. Steve
    Replies:
    3
    Views:
    26,949
    Steve
    Aug 25, 2006
  4. Elhanan
    Replies:
    0
    Views:
    543
    Elhanan
    Jan 23, 2007
  5. llothar
    Replies:
    17
    Views:
    1,246
    Steve Holden
    Apr 7, 2008
Loading...

Share This Page