[cairo] Building on Windows

Thorgrimsson, Chris Chris.Thorgrimsson at lamresearch.com
Fri Sep 25 10:26:21 PDT 2009


To get Cairo to build for win32, I followed the guidance from the
README.win32 as well as some steps under the "Building On Windows"
category. For me, it was a combination of both, and it wasn't the
easiest since I am not that familiar with makefiles. I guess I have been
spoiled by visual studio over the years (or corrupted depending on how
you look at it).  

I did need to modify several makefiles that came with the project as per
the readme. Since I am green when it comes to makefiles, my
modifications may not be in the best form and I am almost certain that
others would need to tweak the hard coded paths that I incorporated.
There were a couple of prerequisites that I didn't find out about until
my first few attempts to compile, but hopefully I have listed them
below. Anyway, here is what I did.

Things I needed \ used:
Used Visual Studio 2008
- I have the pro edition, but it seems other have been successful with
the express editions. All you want out of it is the compiler and linker,
so I can't think of why the express edition won't work.

Needed Microsoft Windows SDK v7.0: 
- provides lib files for gdi32.lib msimg32.lib and user32.lib
- free to download!

Needed Sources:
-zlib (I used 1.2.3) 
-libpng (I used 1.2.40)
-cairo (I used 1.8.8)
-pixman (I used 0.16.0)

Used DependancyWalker:
-not needed for building, but an invaluable tool to check out the dll
after it was built to see all the other dll dependencies and if they are
present on your system. It's a great tool and very easy to use. You can
get it for free at: www.dependencywalker.com

The first couple of steps in the building on windows category say to get
and build zlib and then libpng. I found everything I needed at
"www.libpng.org/pub/png/libpng.html". I got the zip version of 1.2.40
and then followed the link on the same page to the zlib site and got the
source for zlib 1.2.3. Contained within the libpng zip, was a visual
studio 7 project (..\libpng-1.2.40\projects\visualc71) that worked out
of the box. After the build, I had the libs and dlls for libpng and
zlib. It was nice that it took care of both libpng and zlib within the
same project. I didn't bother with building pngtest.

I went the route of MozillaBuild, not CYGWIN. The link to MozillaBuild
provided everything I needed and the subsequent steps about modifying
the batch file was easy enough. From that point on, I needed to modify
the various win32 make files and add the needed feature\version header
files to get Cairo to build. All the modifications to the various
makefiles are a bit much to put into the email, so if you or anyone else
would like, I can email you my versions of the files and you can diff
them with the originals to see how you might tailor the various paths to
suite your environment. I can also send the feature and header files I
used. Basically, all the modifications to the makefiles were related to
setting paths for libraries, includes and sources.

One final step that I needed to deal with after the build generated the
DLL was to embed the matching manifest that was also created. This could
have been done during the build, but I didn't really understand the
explanation given at the msdn site so I did it using the command line
tools. The how-to for both methods can be found at
"www.msdn.microsoft.com/en-us/library/ms235591(VS.80).aspx".  Another
side effect of how I built the dll was that I now also need to
distribute the msvcr90.dll with the libcairo-2.dll. This is the
Microsoft C runtime dll. It's an additional dll that I now need to worry
about with my distribution, but one I can deal with for now.

Hope this helps, and if you need more detail, let me know.

FYI...it's all working well in VisualWorks7.4 thanks to all the work you
did on the bindings. THANKS!!! 


-----Original Message-----
From: cairo-bounces at cairographics.org
[mailto:cairo-bounces at cairographics.org] On Behalf Of Travis Griggs
Sent: Wednesday, September 23, 2009 10:14 PM
To: cairo list
Subject: [cairo] Building on Windows

I've run across at least 2 descriptions of how to build Cairo for Win32.

1) The 'Build on Windows' section of http://cairographics.org/download/

2) The README.win32 in the Cairo distribution (1.8.8).

They don't seem quite in sync, or at all. What is the status of  
either? What is considered the current best/easiest way to build for  
Windows. Is it either of those? or something completely different?


Travis Griggs
Time and Countertops. They both get used up way too fast.

cairo mailing list
cairo at cairographics.org

More information about the cairo mailing list