Python extension on Windows

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David Isal

    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:[color=blue]
    >g++ -I/cygdrive/c/python22/include -c demomodule.cpp -o demomodule.o[/color]

    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.

  • Gerhard Häring

    #2
    Re: Python extension on Windows

    David Isal wrote:[color=blue]
    > hi all,
    > i'm new to python and i'm trying to build a python extension on win98,
    > written in c++, with cygwin.^[/color]

    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.
    [color=blue]
    > but i keep having the same error message, and i didnt't find much
    > resources on the web about it:[color=green]
    > >g++ -I/cygdrive/c/python22/include -c demomodule.cpp -o demomodule.o[/color]
    >
    > 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?)."[/color]

    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.
    [color=blue]
    > 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.[/color]

    That's wrong. See

    [color=blue]
    > does anybody has advices about that?[/color]

    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=mingw3 2

    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

    Comment

    • Peter Scott

      #3
      Re: Python extension on Windows

      David Isal <david.isal@wan adoo.fr> wrote in message news:<bemf6t$l1 r$1@news-reader4.wanadoo .fr>...[color=blue]
      > 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.[/color]

      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 incompatibiliti es between compilers.

      The source tarball is at
      <http://python.org/ftp/python/2.2.3/Python-2.2.3.tgz>.

      Comment

      • David Isal

        #4
        Re: Python extension on Windows

        thank you guys for your advices ;-)

        Comment

        Working...