[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
necessary.

Best,
Antoine

-----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

Hi,

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  
share...

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 
\Makefile.win32
- 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...

Sincerly,
Stefan


TO BUILD CAIRO WITH VISUAL STUDIO 2005

Define some cairo source root directory:
$(CAIRO_ROOT)=c:\Attic\Cairo

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):
$(CAIRO_ROOT)\zlib_1.2.3\include
$(CAIRO_ROOT)\zlib_1.2.3\lib

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/ 
$(CFG)/pixman-1.lib

Environment Variables to set via the System Properties
CAIRO_ROOT = c:\Attic\Cairo
LIBPNG_CURRENT = %CAIRO_ROOT%\libpng_1.2.31
ZLIB_CURRENT = %CAIRO_ROOT%\zlib_1.2.3
CAIRO_SRC_CURRENT = %CAIRO_ROOT%\cairo_head
PIXMAN_SRC_CURRENT = %CAIRO_ROOT%\pixman_head
CAIRO_BUILD = %CAIRO_ROOT%\cairo_build
MOZILLA_BUILD_ENVIRONMENT = c:\mozilla-build

In VisualStudio add to Tools>Options>Projects and Solutions>VC++  
Directories
Include files
$(PIXMAN_SRC_CURRENT)\pixman
$(LIBPNG_CURRENT)\include
$(ZLIB_CURRENT)\include
Library files
$(LIBPNG_CURRENT)\lib
$(ZLIB_CURRENT)\lib

Create a new project named cairo and store it in the solution $ 
(CAIRO_ROOT)\msvc\cairolib
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
$(PIXMAN_BUILD)\$(ConfigurationName)
Intermediate Directory
$(PIXMAN_BUILD)\$(ConfigurationName)

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

Configuration Properties>NMake (Debug)
Build Command Line
cd $(PIXMAN_SRC_CURRENT)\pixman
$(MOZILLA_BUILD_ENVIRONMENT)\msys\local\bin\make.exe -f Makefile.win32  
CFG=debug
Clean Command Line
cd $(PIXMAN_SRC_CURRENT)\pixman
$(MOZILLA_BUILD_ENVIRONMENT)\msys\local\bin\make.exe -f Makefile.win32  
clean

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

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

This gives me for debug
$(PIXMAN_SRC_CURRENT)\pixman\debug\pixman-1.lib
$(CAIRO_SRC_CURRENT)\src\debug\cairo-static.lib
$(CAIRO_SRC_CURRENT)\boilerplate\debug\boiler.lib

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
http://lists.cairographics.org/mailman/listinfo/cairo



More information about the cairo mailing list