0

I'm trying to compile Python Imaging Library on Windows 7 64-bit by running

pip install pil

I've set my compiler to MinGW. It looks like it's going fine until it's time to compile _imaging.c. It fails on this monster gcc call:

 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

The error from this call starts off like:

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'

I assume these weird undefined things are part of the Python C API. So why would I get these errors if the gcc call is including -lpython27?

2
  • What OS are you using? There are known issues with this in Windows. Commented Oct 16, 2012 at 3:22
  • Sorry, added my OS. It's Windows 7 64-bit Commented Oct 16, 2012 at 13:00

1 Answer 1

0

There are a lot of known problems with compiling in Windows as part of Python package installation. I'd recommend that you go with the Unofficial Windows Binaries that have worked for me in the past.

You could install PIL with:

easy_install http://www.lfd.uci.edu/~gohlke/pythonlibs/xos8d83j/PIL-fork-1.1.7.win-amd64-py2.7.exe
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the work around, but I'd still like to know why the compiler does not succeed. Wouldn't that qualify as a compiler bug?
A compiler bug, maybe, but it's definitely more complicated and there are a lot of moving parts with getting the compilers working on Windows. See here and also look up other Windows gcc compilation issues; you'll find lots of reports of it. As for why it doesn't work, I don't exactly know. I know it's an open issue though--I forget whether with Python or with GCC or Mingw.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.