problem in compiling C API in mingw

Thomas Jollans t at jollybox.de
Wed Jul 27 02:27:52 CEST 2011


On 27/07/11 01:53, llwaeva at gmail.com wrote:
> 
> $ python setup.py build --compiler=mingw32
> running build
> running build_ext
> building 'example' extension
> D:\Programs\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall "-Ic:\Program Files (x8
> 6)\Python\include" "-Ic:\Program Files (x86)\Python\PC" -c example.c -o build\te
> mp.win-amd64-3.1\Release\example.o
> writing build\temp.win-amd64-3.1\Release\example.def
> D:\Programs\MinGW\bin\gcc.exe -mno-cygwin -shared -s build\temp.win-amd64-3.1\Re
> lease\example.o build\temp.win-amd64-3.1\Release\example.def "-Lc:\Program Files
>  (x86)\Python\libs" "-Lc:\Program Files (x86)\Python\PCbuild\amd64" -lpython31 -
> lmsvcr90 -o build\lib.win-amd64-3.1\example.pyd
> build\temp.win-amd64-3.1\Release\example.o:example.c:(.text+0x13): undefined ref
> erence to `_imp___Py_NoneStruct'
> build\temp.win-amd64-3.1\Release\example.o:example.c:(.text+0x32): undefined ref
> erence to `_imp__PyModule_Create2'
> collect2: ld returned 1 exit status
> error: command 'gcc' failed with exit status 1
> --------------------- Original Message Ends --------------------

Curious. You appear to be using a 32-bit C compiler (mingw32), and
Python appears to be installed in "Program Files (x86)", suggesting a
32-bit version, but distutils appears to generate directory names of the
format "XXX.win-amd64-3.1" - suggesting some kind of architecture
conflict. Then again, I remember some bug about Python reporting the
wrong architecture on Windows, so this could just be a fluke, but if
your extension and Python were built for different architectures that
would explain it.

So the best advice I can offer at this point is: install Python 3.2, and
make sure that either (a) you use a 64-bit compiler (and Python), or (b)
you use a 32-bit Python (and compiler).



More information about the Python-list mailing list