[cairo] Description of how to build Cairo with VisualStudio

Antoine Azar cairo at antoineazar.com
Mon Sep 1 13:12:50 PDT 2008

Hey Stefan, great job detailing the steps to build on Win32. You should
consider integrating your work into the cairographics.org wiki.

Concerning this:
> copy pixman\pixman\pixman-version.h.inc to \pixman\pixman\pixman-version.h
and replace the @variables with 0.11.9
> copy cairo\src\cairo-features-win32.h to cairo\src\cairo-features.h

Behdad has fixed (or is fixing) the makefiles so this is no longer


-----Original Message-----
From: cairo-bounces at cairographics.org
[mailto:cairo-bounces at cairographics.org] On Behalf Of Stefan Landvogt
Sent: Monday, September 01, 2008 7:00 AM
To: cairo at cairographics.org
Subject: [cairo] Description of how to build Cairo with VisualStudio


I just edited a ReadMe.txt as a reminder for myself what was necessary  
to create a VisualStudio solution for Cairo, so I can start developing  
for myself in the IDE. Maybe this is of interest for some other people  
as well... Maybe someone else has a better solution and is willing to  

This is by no means a perfect way to do it: Just what was necessary to  
get me going. Maybe this can be a starting point for a more  
VisualStudio savvy person than me to make it "right". Especially with  
the environment variables and where the output goes, but I think it  
should be possible to build the project in VisualStudio independent  
from where the source is located without cluttering the project by  
VisualStudio project files.

Maybe there could be an IDE directory in Cairo, where e.g.  
VisualStudio or Xcode project files live. I would love to have these  
as a permanent addition to Cairo.

There were some obstacles, that I personally did not like so much  
(indpendent from VisualStudio):
- I had to edit/create two header files and a makefile manually
- it is unclear to me how the pixman-version.h file gets his "values",  
so I just guessed
- the path to the created pixman library is hardcoded in cairo 
- the makefiles are asking for debug and release while VisualStudio  
uses Debug and Release as Configuration names: it would help if this  
would not be case sensitive
- I was not able to control where the output (the lib files) goes: I  
would love to be able to define some output directory.

Anyway: the whole approach was based by some Visual Studio solution  
file Antoine Azar gave me, so my kudos to him...



Define some cairo source root directory:

Get the mozilla buidl environment and install it to c:\mozilla-build

Get the project via git. In my case cd to $(CAIRO_ROOT)
git clone git://anongit.freedesktop.org/git/pixman pixman_head
git clone git://anongit.freedesktop.org/git/cairo cairo_head

Get libpng and save it in the following layout (after building):
$(CAIRO_ROOT)\libpng_1.2.31\include contains the include file
$(CAIRO_ROOT)\libpng_1.2.31\lib contains the library

Get zlib and save it in the following layout (after building):

Changes to original project
copy pixman\pixman\pixman-version.h.inc to \pixman\pixman\pixman- 
version.h and replace the @variables with 0.11.9
copy cairo\src\cairo-features-win32.h to cairo\src\cairo-features.h
modified cairo\Makefile.win32: PIXMAN_LIBS := ../../pixman_head/pixman/ 

Environment Variables to set via the System Properties
CAIRO_ROOT = c:\Attic\Cairo
CAIRO_BUILD = %CAIRO_ROOT%\cairo_build

In VisualStudio add to Tools>Options>Projects and Solutions>VC++  
Include files
Library files

Create a new project named cairo and store it in the solution $ 
Create a new project named pixman and add it to the solution
Create a new project named boilerplate and add it to the solution

Rightclick on pixman and select Properties and edit:
Configuration Properties>General:
Output Directory
Intermediate Directory

(But this is only cosmetics if you dont want to have output from  
VisualStudio cluttered)

Configuration Properties>NMake (Debug)
Build Command Line
$(MOZILLA_BUILD_ENVIRONMENT)\msys\local\bin\make.exe -f Makefile.win32  
Clean Command Line
$(MOZILLA_BUILD_ENVIRONMENT)\msys\local\bin\make.exe -f Makefile.win32  

Do the similiar thing for cairo and boilerplate. For cairo to get the  
static library use for
Build Command Line
$(MOZILLA_BUILD_ENVIRONMENT)\msys\local\bin\make.exe -f Makefile.win32  
static CFG=debug

Build every project independently in the order: pixman, cairo,  

This gives me for debug

I was not interested in the test and perf directories. Sorry.

If you want the header and source files to be editable in VisualStudio  
add the .h and .c files to the project, but be aware that the actual  
compiled files are controlled by the makefile.

The resulting "solution" directory is available upon request...

cairo mailing list
cairo at cairographics.org

More information about the cairo mailing list