FAQ
Hello,

I have been trying unsuccessfully to use Cygwin/gcc to build Python
extensions for native Windows Python 2.2 on Windows XP. I followed
the general outline at
http://python.sourceforge.net/devel-docs/inst/non-ms-compilers.html

Summary of problem (whether I use distutils, or just try to "do it
by hand"): I get a linker failure, from undefined references
to "libpython22_a_iname" and "_nm___Py_NoneStruct".

Has anyone else had success building an extension module with Windows
Python 2.2 and Cygwin/gcc?

Thanks,
--Les Button
lbut at stny.rr.com

P.S. I also had a problem with "Python.h" needing to have definitions of
SIZEOF_INT
and SIZEOF_LONG; these apparently didn't get defined properly (for
Cygwin/gcc)
in "pyconfig.h"?? I fixed for now by providing #define's for these two,
before the
#include "Python.h" -- I don't see why this should be related to the linker
failure.

pexports version 0.43
dlltool version 2.11.92 20011001
gcc version 2.95.3-5
Windows Python 2.2
Windows XP (home edition)

******** Attempted build: *********
$ ./pexports python22.dll > python22.def
$ dlltool --dllname python22.dll --def
python22.def --output-lib=libpython22.a
$ cp libpython22.a /cygdrive/c/Python22/libs
$ python setup.py build --compiler=cygwin
running build
running build_ext
building 'pr_int' extension
creating build
creating build\temp.win32-2.2
creating build\temp.win32-2.2\Release
C:\cygwin\bin\gcc.exe -mcygwin -mdll -O -Wall -Ic:\Python22\include -c
pr_int.c
-o build\temp.win32-2.2\Release\pr_int.o
writing build\temp.win32-2.2\Release\pr_int.def
creating build\lib.win32-2.2
C:\cygwin\bin\gcc.exe -mcygwin -mdll -static -s
build\temp.win32-2.2\Release\pr_
int.o
build\temp.win32-2.2\Release\pr_int.def -Lc:\Python22\libs -lpython22 -o b
uild\lib.win32-2.2\pr_int.pyd
Warning: resolving __Py_NoneStruct by linking to __imp___Py_NoneStruct
(auto-imp
ort)
fu000001.o(.idata$3+0xc): undefined reference to `libpython22_a_iname'
fu000002.o(.idata$3+0xc): undefined reference to `libpython22_a_iname'
nmth000000.o(.idata$4+0x0): undefined reference to `_nm___Py_NoneStruct'
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1

******** setup.py: *********
import sys

from distutils.core import setup
from distutils.extension import Extension

setup (
name = "pr_int",

ext_modules = [Extension(
name="pr_int",
sources = [ "pr_int.c" ]
)],
)

Search Discussions

  • Gerhard Häring at Mar 18, 2002 at 12:28 am

    * Les Button [2002-03-17 15:21 +0000]:
    Has anyone else had success building an extension module with Windows
    Python 2.2 and Cygwin/gcc?
    Yes, me. Though I now prefer mingw.

    I just used this instead of pexports:
    http://cygwin.com/cygwin-ug-net/dll.html#DLL-LINK

    Gerhard
    --
    This sig powered by Python!
    Au?entemperatur in M?nchen: 8.1 ?C Wind: 1.0 m/s
  • Anton Vredegoor at Mar 18, 2002 at 10:57 am

    On Sun, 17 Mar 2002 15:21:19 GMT, "Les Button" wrote:
    Has anyone else had success building an extension module with Windows
    Python 2.2 and Cygwin/gcc?
    Yes, I can build extensions for python 2.2 on windows 98 SE using
    cygwin.
    P.S. I also had a problem with "Python.h" needing to have definitions of
    SIZEOF_INT
    and SIZEOF_LONG; these apparently didn't get defined properly (for
    Cygwin/gcc)
    in "pyconfig.h"?? I fixed for now by providing #define's for these two,
    before the
    #include "Python.h" -- I don't see why this should be related to the linker
    failure.
    Probably you should reverse these changes for the solution below to
    work.
    $ python setup.py build --compiler=cygwin
    try:
    setup.py build --compiler=mingw32

    Good luck,
    Anton.
  • Jason Tishler at Mar 18, 2002 at 12:49 pm
    Les,
    On Mon, Mar 18, 2002 at 11:57:14AM +0100, Anton Vredegoor wrote:
    On Sun, 17 Mar 2002 15:21:19 GMT, "Les Button" wrote:
    $ python setup.py build --compiler=cygwin
    try:
    setup.py build --compiler=mingw32
    I concur with Anton that the "--compiler=mingw32" is required to build
    Win32 Python extensions with Cygwin gcc -mno-cygwin.

    FWIW, this is how I build the Win32 Python readline extension.

    Jason
  • Les Button at Mar 18, 2002 at 9:36 pm
    "Anton Vredegoor" <anton at vredegoor.doge.nl> wrote in message
    news:a74hef$ejq$1 at news.hccnet.nl...
    try:
    setup.py build --compiler=mingw32
    Works great! (and doesn't have problem with undefined SIZEOF_INT etc).
    Thanks very much indeed,
    --Les Button

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedMar 17, '02 at 3:21p
activeMar 18, '02 at 9:36p
posts5
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase