[Image-SIG] cross-compilation

Fredrik Lundh fredrik at pythonware.com
Sun Apr 23 08:30:47 CEST 2006

Nicolas Pinault wrote:

> I'd like to cross compile PIL for an arm based linux board.
> How can I do this ?

I'm not sure if distutils supports cross-compilation, but people are porting
my distutils-stuff to the oddest platforms, so it's definitely possible.

if you cannot get distutils to do this for you, you may have to create
your own build files.  here's an outline:

first, figure out if you want JPEG, PNG, and Freetype support.  if you do,
you have to build the necessary libraries.  see the README file for URLs.

the core library consists of two parts; the libImaging support library, and
the _imaging Python binding.

it's probably easiest to build each part for itself.

the libImaging source code is located in the libImaging directory (not very
surprising).  to build this as a library, edit the ImConfig.h file to suit your
configuration, and then build a library out of all files in the directory, minus
Except.c and coretest.c.

here's the complete list of core files (without extensions):

    "Access", "Antialias", "Bands", "BitDecode", "Blend", "Chops",
    "Convert", "ConvertYCbCr", "Copy", "Crc32", "Crop", "Dib", "Draw",
    "Effects", "EpsEncode", "File", "Fill", "Filter", "FliDecode",
    "Geometry", "GetBBox", "GifDecode", "GifEncode", "HexDecode",
    "Histo", "JpegDecode", "JpegEncode", "LzwDecode", "Matrix",
    "ModeFilter", "MspDecode", "Negative", "Offset", "Pack",
    "PackDecode", "Palette", "Paste", "Quant", "QuantHash",
    "QuantHeap", "PcdDecode", "PcxDecode", "PcxEncode", "Point",
    "RankFilter", "RawDecode", "RawEncode", "Storage", "SunRleDecode",
    "TgaRleDecode", "Unpack", "UnpackYCC", "XbmDecode", "XbmEncode",
    "ZipDecode", "ZipEncode"

the coretest.c file contains a simple test program; you can try building
that and linking that against the libImaging library and the Except.c file
(but I have to admit that haven't tried that in years, so if you stumble
upon problems, it may be coretest's fault)

anyway, when you've successfully built the library, it's time to build the
_imaging binding.  the sources for the binding is located in the PIL source
directory, and consists of _imaging.c plus the following files:

    "decode", "encode", "map", "display", "outline", "path",

if you build these, and link the result against libImaging, you should have
a working PIL binding.  good luck!


More information about the Image-SIG mailing list