使用MinGW编译Python Imaging Library

时间:2012-10-16 02:57:03

标签: mingw python-imaging-library python-c-api

我正在尝试通过运行

Windows 7 64位上编译Python Imaging Library
pip install pil

我已将编译器设置为MinGW。在编译_imaging.c之前,它看起来很好。它在这个怪物gcc电话上失败了:

 C:\MinGW\bin\gcc.exe -shared -s build\temp.win-amd64-2.7\Release\_imaging.o build\temp.win-amd64-2.7\Release\decode.o build\temp.win-amd64-2.7\Release\encode.o build\temp.win-amd64-2.7\Release\map.o build\temp.win-amd64-2.7\Release\display.o build\temp.win-amd64-2.7\Release\outline.o build\temp.win-amd64-2.7\Release\path.o build\temp.win-amd64-2.7\Release\libimaging\access.o build\temp.win-amd64-2.7\Release\libimaging\antialias.o build\temp.win-amd64-2.7\Release\libimaging\bands.o build\temp.win-amd64-2.7\Release\libimaging\bitdecode.o build\temp.win-amd64-2.7\Release\libimaging\blend.o build\temp.win-amd64-2.7\Release\libimaging\chops.o build\temp.win-amd64-2.7\Release\libimaging\convert.o build\temp.win-amd64-2.7\Release\libimaging\convertycbcr.o build\temp.win-amd64-2.7\Release\libimaging\copy.o build\temp.win-amd64-2.7\Release\libimaging\crc32.o build\temp.win-amd64-2.7\Release\libimaging\crop.o build\temp.win-amd64-2.7\Release\libimaging\dib.o build\temp.win-amd64-2.7\Release\libimaging\draw.o build\temp.win-amd64-2.7\Release\libimaging\effects.o build\temp.win-amd64-2.7\Release\libimaging\epsencode.o build\temp.win-amd64-2.7\Release\libimaging\file.o build\temp.win-amd64-2.7\Release\libimaging\fill.o build\temp.win-amd64-2.7\Release\libimaging\filter.o build\temp.win-amd64-2.7\Release\libimaging\flidecode.o build\temp.win-amd64-2.7\Release\libimaging\geometry.o build\temp.win-amd64-2.7\Release\libimaging\getbbox.o build\temp.win-amd64-2.7\Release\libimaging\gifdecode.o build\temp.win-amd64-2.7\Release\libimaging\gifencode.o build\temp.win-amd64-2.7\Release\libimaging\hexdecode.o build\temp.win-amd64-2.7\Release\libimaging\histo.o build\temp.win-amd64-2.7\Release\libimaging\jpegdecode.o build\temp.win-amd64-2.7\Release\libimaging\jpegencode.o build\temp.win-amd64-2.7\Release\libimaging\lzwdecode.o build\temp.win-amd64-2.7\Release\libimaging\matrix.o build\temp.win-amd64-2.7\Release\libimaging\modefilter.o build\temp.win-amd64-2.7\Release\libimaging\mspdecode.o build\temp.win-amd64-2.7\Release\libimaging\negative.o build\temp.win-amd64-2.7\Release\libimaging\offset.o build\temp.win-amd64-2.7\Release\libimaging\pack.o build\temp.win-amd64-2.7\Release\libimaging\packdecode.o build\temp.win-amd64-2.7\Release\libimaging\palette.o build\temp.win-amd64-2.7\Release\libimaging\paste.o build\temp.win-amd64-2.7\Release\libimaging\quant.o build\temp.win-amd64-2.7\Release\libimaging\quanthash.o build\temp.win-amd64-2.7\Release\libimaging\quantheap.o build\temp.win-amd64-2.7\Release\libimaging\pcddecode.o build\temp.win-amd64-2.7\Release\libimaging\pcxdecode.o build\temp.win-amd64-2.7\Release\libimaging\pcxencode.o build\temp.win-amd64-2.7\Release\libimaging\point.o build\temp.win-amd64-2.7\Release\libimaging\rankfilter.o build\temp.win-amd64-2.7\Release\libimaging\rawdecode.o build\temp.win-amd64-2.7\Release\libimaging\rawencode.o build\temp.win-amd64-2.7\Release\libimaging\storage.o build\temp.win-amd64-2.7\Release\libimaging\sunrledecode.o build\temp.win-amd64-2.7\Release\libimaging\tgarledecode.o build\temp.win-amd64-2.7\Release\libimaging\unpack.o build\temp.win-amd64-2.7\Release\libimaging\unpackycc.o build\temp.win-amd64-2.7\Release\libimaging\unsharpmask.o build\temp.win-amd64-2.7\Release\libimaging\xbmdecode.o build\temp.win-amd64-2.7\Release\libimaging\xbmencode.o build\temp.win-amd64-2.7\Release\libimaging\zipdecode.o build\temp.win-amd64-2.7\Release\libimaging\zipencode.o build\temp.win-amd64-2.7\Release\_imaging.def -LC:\Python27\lib -LC:\Python27\libs -LC:\Python27\PCbuild\amd64 -lkernel32 -luser32 -lgdi32 -lpython27 -lmsvcr90 -o build\lib.win-amd64-2.7\_imaging.pyd

此次通话的错误开始于:

build\temp.win-amd64-2.7\Release\_imaging.o:_imaging.c:(.text+0x70): undefined reference to `__imp__PyFloat_Type'
build\temp.win-amd64-2.7\Release\_imaging.o:_imaging.c:(.text+0x78): undefined reference to `__imp__PyFloat_Type'
build\temp.win-amd64-2.7\Release\_imaging.o:_imaging.c:(.text+0x85): undefined reference to `__imp__PyType_IsSubtype'
build\temp.win-amd64-2.7\Release\_imaging.o:_imaging.c:(.text+0xc9): undefined reference to `__imp__PyFloat_Type'
build\temp.win-amd64-2.7\Release\_imaging.o:_imaging.c:(.text+0xd1): undefined reference to `__imp__PyFloat_Type'
build\temp.win-amd64-2.7\Release\_imaging.o:_imaging.c:(.text+0xde): undefined reference to `__imp__PyType_IsSubtype'
build\temp.win-amd64-2.7\Release\_imaging.o:_imaging.c:(.text+0x113): undefined reference to `__imp__PyExc_TypeError'
build\temp.win-amd64-2.7\Release\_imaging.o:_imaging.c:(.text+0x11e): undefined reference to `__imp__PyErr_SetString'
build\temp.win-amd64-2.7\Release\_imaging.o:_imaging.c:(.text+0x132): undefined reference to `__imp__PyExc_TypeError'
build\temp.win-amd64-2.7\Release\_imaging.o:_imaging.c:(.text+0x13d): undefined reference to `__imp__PyErr_SetString'
build\temp.win-amd64-2.7\Release\_imaging.o:_imaging.c:(.text+0x194): undefined reference to `__imp__PyInt_AsLong'
build\temp.win-amd64-2.7\Release\_imaging.o:_imaging.c:(.text+0x1a3): undefined reference to `__imp__PyErr_Occurred'
build\temp.win-amd64-2.7\Release\_imaging.o:_imaging.c:(.text+0x23e): undefined reference to `__imp__PyArg_ParseTuple'
build\temp.win-amd64-2.7\Release\_imaging.o:_imaging.c:(.text+0x285): undefined reference to `__imp__PyArg_ParseTuple'
build\temp.win-amd64-2.7\Release\_imaging.o:_imaging.c:(.text+0x316): undefined reference to `__imp__PyInt_AsLong'
build\temp.win-amd64-2.7\Release\_imaging.o:_imaging.c:(.text+0x325): undefined reference to `__imp__PyErr_Occurred'
build\temp.win-amd64-2.7\Release\_imaging.o:_imaging.c:(.text+0x341): undefined reference to `__imp__PyFloat_AsDouble'
build\temp.win-amd64-2.7\Release\_imaging.o:_imaging.c:(.text+0x35f): undefined reference to `__imp__PyErr_Occurred'
build\temp.win-amd64-2.7\Release\_imaging.o:_imaging.c:(.text+0x393): undefined reference to `__imp__PyInt_AsLong'

我认为这些奇怪的未定义的东西是Python C API的一部分。那么,如果gcc调用包含-lpython27,为什么会出现这些错误?

1 个答案:

答案 0 :(得分:0)

作为Python软件包安装的一部分,在Windows中进行编译存在许多已知问题。我建议您使用过去曾为我工作过的Unofficial Windows Binaries

你可以用:

安装PIL
easy_install http://www.lfd.uci.edu/~gohlke/pythonlibs/xos8d83j/PIL-fork-1.1.7.win-amd64-py2.7.exe