[cairo] Compiling Cairo with MinGW under Win32

Andrew Johnson acjgenius at earthlink.net
Sat Oct 30 06:04:21 PDT 2004


On Sat, 2004-10-30 at 14:16 +0200, Jost Boekemeier wrote: 
>  --- Jack Chen <jacks_small_world at yahoo.com> schrieb: 
> > compile Cairo with the MinGW compiler under Win32.
> 
> Forget that.  MinGW is, as the name suggests, a thin
> wrapper around the win32 API.  No X11, no sockets, no
> processes, pipes, nothing.
> 

you can indeed compile it using mingw, with msys and the msys developers
kit to provide the auto tools etc. Its not like you NEED X11 to compile
cairo, which is half the beauty of it.

> Compiling it with cygwin will (well, should) work,
> however.  Note that the cygwin DLL's are covered by
> the GPL.  That means that the resulting cairo w32 is
> covered by the GPL, too.

You don't need cygwin dll, cairo doesn't rely on anything unix system
dependent, it is after all a GRAPHICS library.

I have several times compiled pixman and cairo with mingw and the
autotools as ported by msys. the only problem is the final linking
occasionally fails due to a libtool bug(I presume), so I rerun the gcc
command manually(Or in my case, just made a quick sh script to do it for
me.)

The only major depend issues are fontconfig and freetype, which are
available for win32 from either gnuwin32, or the gtk+ runtime/developers
kit(I used the glade kit as it was the most up to date and complete).

By default with no extra depends you can get the pixman backend, and the
ps backend. With the gnuwin32 or gtk+ libpng and headers manually put
into the mingw path you can get the png backend, though it seems that
recent libpng's are broken in that they output empty files, so the png
backend is currently useless anyway.

Additionally from an earlier thread Tor was planning on making a wgl
backend for glitz, allowing the glitz backend to work on windows
natively as well, so that may happen before long.

libsvg and libsvg-cairo also compile, though they require a bit more
work and always require manual linking. I think this is a flaw in the
configure not mingw though. (haven't bothered to document the problems I
have had so I can't be more specific without trying from scratch again).

Basic setup from scratch would go something like this -

install latest mingw setup
install latest msys setup
install latest msysdk setup

install the glade gtk+ runtime & developers kit

add the GTK+ directory to the msys fstab (/GTK for instance),
so you can use configure --install=/GTK

try and autogen.sh/make/make install libpixman

linking may fail dependent on versions of things about missing windows
headers, the headers are there, but libtool is stupid and can't find
-lgdi32 sometimes(only sometimes!), libpixman doesn't actually need the
win32 headers, so rerun the link command manually without the -lgdi32

make install

try and autogen.sh/make/make install cairo

same as above to fix issues.

one issue I did have in use is with fontconfig

fontconfig has to cache the fonts internally every time if the cache
file doesn't exist but fc-cache doesn't work, to solve this I created a
custom build of fontconfig which saves the internal cache file on
changes.

This isn't an easy fix for most people(though its only one line change)
but its something to consider, as it means the first time a cairo
context is created it can take 30seconds-2minutes cache time depending
on total number of fonts and cpu speed.

Andrew




More information about the cairo mailing list