Obtaining and installing 32 and 64 bit Cairo DLLs for cairocffi under Windows

I was trying to set up the Cairo library in order to test the Phoenix version of wx.lib.pdfviewer which uses Cairo if it’s available, otherwise wx.GraphicsContext is used.I found an installer for the pycairo bindings for Python 2.7 but not for any Python 3.x so I was delighted to discover Robin has used his time machine and incorporated use of the later, and replacement, cairocffi bindings into the Phoenix snapshot builds :slight_smile:

In wxcairo.init Robin explains how to obtain and install the underlying Cairo DLLs that cairocffi uses and points to http://www.gtk.org/download/windows.php which appears to recommend installing MSYS2. I may have misread things or taken a wrong turn somwhere but I didn’t get very far with that. Instead I followed advice I read somewhere to install the runtimes for GTK+ and use the Cairo libraries from there.

The 32 bit Windows installer is gtk2-runtime-2.24.10-2012-10-10-ash.exe and can be obtained from http://gtk-win.sourceforge.net/home/index.php/Main/Downloads. It installs to C:\Program Files (x86)\GTK2-Runtime with the DLLs in \bin and the installer adds this location to your PATH

If running 64 bit Python install using gtk2-runtime-2.24.30-2016-04-09-ts-win64.exe from https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer which installs to C:\Program Files\GTK2-Runtime Win64 with the DLLs in \bin. This installer also adds this location to your PATH.

If you need to work with both 32 and 64 bit versions as I do, in different virtualenvs, you can take advantage of the fact that the \Scripts directory of the currently active environment is automatically pre-pended to the PATH so the corresponding DLLs can be copied there.

For 32 bit Cairo the required files are:

Directory of E:\PyDevSrc7\Dp710\env2.7\Scripts

27/12/2010 10:12 538,324 freetype6.dll
22/11/2011 06:48 1,294,335 libcairo-2.dll
31/01/2009 18:42 143,096 libexpat-1.dll
05/02/2010 17:55 279,059 libfontconfig-1.dll
17/08/2010 12:38 230,529 libpng14-14.dll
20/08/2010 07:18 100,352 zlib1.dll
6 File(s) 2,585,695 bytes

and for 64 bit Cairo are:

Directory of E:\PyDevSrc7\Dp710\env3.4\Scripts

09/04/2016 10:46 38,912 iconv.dll
09/04/2016 06:20 6,322,980 libcairo-2.dll
09/04/2016 06:20 553,680 libfontconfig-1.dll
09/04/2016 06:20 3,447,380 libfreetype-6.dll
09/04/2016 06:20 6,054,068 libpixman-1-0.dll
09/04/2016 06:20 1,210,556 libpng16-16.dll
09/04/2016 06:20 5,887,826 libxml2-2.dll
09/04/2016 06:20 108,544 zlib1.dll
8 File(s) 23,623,946 bytes

Also, the following DLLs are currently included in the distributed wx folder:

28/07/2016 16:06 551,096 freetype6.dll
28/07/2016 16:06 1,182,444 libcairo-2.dll
28/07/2016 16:06 43,987 libcairo-gobject-2.dll
28/07/2016 16:06 182,502 libcairo-script-interpreter-2.dll
28/07/2016 16:06 143,096 libexpat-1.dll
28/07/2016 16:06 279,059 libfontconfig-1.dll
28/07/2016 16:06 230,529 libpng14-14.dll
28/07/2016 16:06 100,352 zlib1.dll

I assume these are 32 bit versions and they should perhaps be removed from there?

In the hope this may be useful.

Regards
David Hughes
Forestfield Software