windows下成功编译Cairo,Compiling Cairo for Windows

Cairo is a cross-platform 2D graphics software library. It is designed to produce consistent output on all output media while taking advantage of display hardware acceleration when available.

Cairo is growing in popularity, and is used in applications such as Firefox 3.

Compiling Cairo can be a long and difficult process, especially if one has never done it before.  The following is a guide to make that task simpler.

Cairo requires several libraries in order to fully compile with PNG and PDF extensions.

1. Download the latest version of Cairo, pixman, libpng, and zlib.  Here are the URLs:

Cairo, pixmanhttp://cairographics.org/releases/
libpnghttp://www.libpng.org/pub/png/libpng.html
zlibhttp://www.zlib.net/

2. Extract the files.  In my case, the resulting directories are:
C:/devel/libs/cairo-1.8.0
C:/devel/libs/pixman-0.12.0
C:/devel/libs/libpng-1.2.32
C:/devel/libs/zlib-1.2.3

Compiling zlib

Open “C:/devel/libs/zlib-1.2.3/contrib/vstudio/vc8/zlibvc.sln” and convert the solution.

Change the “Solutions Platform” in the toolbar from “Itanium” to “Win32″. Make sure “Solution Configurations” in the toolbar is set to “Debug”.

Right click on “zlibvc” in the “Solution Explorer” and go to “Properties”. Perform the following actions:

Location:Variable:Action:
“Configuration Properties” / “C/C++” / “Code Generation”“Runtime Library”Change to “Multi-threaded Debug DLL (/MDd)”
“Configuration Properties” / “C/C++” / “Preprocessor”“Preprocessor Definitions”Delete “ZLIB_WINAPI”
“Configuration Properties” / “Linker” / “General”“Output File”Change to “$(OutDir)/zlib1.dll”
“Configuration Properties” / “Linker” / “Advanced”“Output File”Change to “$(OutDir)/zlib1.lib”

Click on “OK” to close the “Properties” box. Right click on “zlibvc” in the “Solution Explorer”, and click on “Build”.

The output files, “zlib1.lib” and “zlib1.dll”, are located at: “C:/devel/libs/zlib-1.2.3/contrib/vstudio/vc8/x86/ZlibDllDebug”
The zlib include directory is: “C:/devel/libs/zlib-1.2.3″.

Compiling libpng

Open “C:/devel/libs/libpng-1.2.32/projects/visualc71/libpng.sln” and convert the solution.  Delete the “zlib” project from the “Solution Explorer”.

Make sure “Solution Configurations” in the toolbar is set to “DLL ASM Debug”.

Right click on “libpng” in the “Solution Explorer” and go to “Properties”.

Location:Variable:Action:
“Configuration Properties” / “C/C++” / “Code Generation”“Runtime Library”Change to “Multi-threaded Debug DLL (/MDd)”
“Configuration Properties” / “C/C++” / “General”“Additional Include Directories”Change “../../../zlib” to “../../../zlib-1.2.3″
“Configuration Properties” / “Linker” / “General”“Additional Include Directories”Add “../../../zlib-1.2.3/contrib/vstudio/vc8/x86/ZlibDllDebug”
“Configuration Properties” / “Linker” / “Input”“Additional Dependencies”Add “zlib1.lib”

Click on “OK” to close the “Properties” box.  Right click on “libpng” in the “Solution Explorer”, and click on “Build”.

The output files, “libpng13d.lib” and “libpng13d.dll”, are located at: “C:/devel/libs/libpng-1.2.32/projects/visualc71/Win32_DLL_ASM_Debug”
The zlib include directory is: “C:/devel/libs/libpng-1.2.32″.

Compiling Pixman

Pixman includes a makefile for Microsoft Visual Studio’s compiler and linker.  However, the makefile itself is not compatible with Microsoft’s nmake.exe.  A good path to take that does not involve installing Cygwin is to install the MozillaBuild environment.  Visual Studio 9 includes all the necessary windows headers and libraries, but MozillaBuild demands a Windows Platform SDK installation.  Install the Windows Server 2003 version, not the Windows Server 2008 version!  MozillaBuild won’t recognize the latter.

Start MozillaBuild by executing “C:/mozilla-build/start-msvc9.bat”, and go to the pixman directory by executing “cd /c/devel/libs/pixman-0.12.0/pixman”.  Execute “make -f Makefile.win32 CFG=debug”.

The output file, “pixman-1.lib”, will be in the directory “C:/devel/libs/pixman-0.12.0/pixman/debug”.
The pixman include directory is: “C:/devel/libs/pixman-0.12.0/pixman”.

Compiling Cairo

And now, for the last leg of this marathon build session!

Start Microsoft Visual C++ 2008 Express Edition.  Start a new “Empty Project”. Here are my settings:

Name:libcairo
Location:C:/dev/libs/cairo-1.8.0/vs9
Solution Name:libcairo

From “C:/devel/libs/cairo-1.8.0/src”, add the following files to the “Solution Explorer”:

Under “Source Files”Under “Header Files”
cairo-analysis-surface.c
cairo-arc.c
cairo-array.c
cairo-atomic.c
cairo-base85-stream.c
cairo-bentley-ottmann.c
cairo-cache.c
cairo-cff-subset.c
cairo-clip.c
cairo-color.c
cairo-debug.c
cairo-deflate-stream.c
cairo-fixed.c
cairo-font-face.c
cairo-font-options.c
cairo-freelist.c
cairo-gstate.c
cairo-hash.c
cairo-hull.c
cairo-image-surface.c
cairo-lzw.c
cairo-matrix.c
cairo-meta-surface.c
cairo-misc.c
cairo-mutex.c
cairo-output-stream.c
cairo-paginated-surface.c
cairo-path-bounds.c
cairo-path-fill.c
cairo-path-fixed.c
cairo-path-stroke.c
cairo-path.c
cairo-pattern.c
cairo-pdf-operators.c
cairo-pdf-surface.c
cairo-pen.c
cairo-png.c
cairo-polygon.c
cairo-ps-surface.c
cairo-rectangle.c
cairo-region.c
cairo-scaled-font-subsets.c
cairo-scaled-font.c
cairo-skiplist.c
cairo-slope.c
cairo-spline.c
cairo-stroke-style.c
cairo-surface-fallback.c
cairo-surface.c
cairo-svg-surface.c
cairo-system.c
cairo-traps.c
cairo-truetype-subset.c
cairo-type1-fallback.c
cairo-type1-subset.c
cairo-type3-glyph-surface.c
cairo-unicode.c
cairo-user-font.c
cairo-version.c
cairo-wideint.c
cairo-win32-font.c
cairo-win32-printing-surface.c
cairo-win32-surface.c
cairo.c
cairo-analysis-surface-private.h
cairo-arc-private.h
cairo-atomic-private.h
cairo-beos.h
cairo-cache-private.h
cairo-clip-private.h
cairo-compiler-private.h
cairo-deprecated.h
cairo-features.h
cairo-fixed-private.h
cairo-fixed-type-private.h
cairo-freelist-private.h
cairo-gstate-private.h
cairo-hash-private.h
cairo-malloc-private.h
cairo-meta-surface-private.h
cairo-mutex-impl-private.h
cairo-mutex-list-private.h
cairo-mutex-private.h
cairo-mutex-type-private.h
cairo-output-stream-private.h
cairo-paginated-private.h
cairo-paginated-surface-private.h
cairo-path-fixed-private.h
cairo-path-private.h
cairo-pdf-operators-private.h
cairo-pdf-surface-private.h
cairo-pdf.h
cairo-private.h
cairo-ps-surface-private.h
cairo-ps.h
cairo-reference-count-private.h
cairo-region-private.h
cairo-scaled-font-private.h
cairo-scaled-font-subsets-private.h
cairo-skiplist-private.h
cairo-supported-features.h
cairo-surface-fallback-private.h
cairo-surface-private.h
cairo-svg-surface-private.h
cairo-svg.h
cairo-truetype-subset-private.h
cairo-type1-private.h
cairo-type3-glyph-surface-private.h
cairo-types-private.h
cairo-user-font-private.h
cairo-version.h
cairo-wideint-private.h
cairo-wideint-type-private.h
cairo-win32-private.h
cairo-win32.h
cairo.h
cairoint.h

Do not add the following files:

Under “Source Files”Under “Header Files”
cairo-directfb-surface.c
cairo-ft-font.c
cairo-glitz-surface.c
cairo-os2-surface.c
cairo-quartz-font.c
cairo-quartz-surface.c
cairo-xcb-surface.c
cairo-xlib-display.c
cairo-xlib-screen.c
cairo-xlib-surface.c
cairo-xlib-visual.c
check-has-hidden-symbols.c
check-link.c
test-fallback-surface.c
test-meta-surface.c
test-paginated-surface.c
cairo-directfb.h
cairo-ft-private.h
cairo-ft.h
cairo-glitz-private.h
cairo-glitz.h
cairo-os2-private.h
cairo-os2.h
cairo-quartz-private.h
cairo-quartz.h
cairo-xcb-xrender.h
cairo-xcb.h
cairo-xlib-private.h
cairo-xlib-surface-private.h
cairo-xlib-xrender-private.h
cairo-xlib-xrender.h
cairo-xlib.h
test-fallback-surface.h
test-meta-surface.h
test-paginated-surface.h

Open “cairo-features.h” from the “Solution Explorer” and replace its contents with the following:

#ifndef CAIRO_FEATURES_H
#define CAIRO_FEATURES_H

#define CAIRO_HAS_FT_FONT 0
#define CAIRO_HAS_IMAGE_SURFACE 1
#define CAIRO_HAS_PDF_SURFACE 1
#define CAIRO_HAS_PNG_FUNCTIONS 1
#define CAIRO_HAS_PS_SURFACE 1
#define CAIRO_HAS_SVG_SURFACE 1
#define CAIRO_HAS_USER_FONT 1
#define CAIRO_HAS_XLIB_SURFACE 0
#define CAIRO_HAS_XLIB_XRENDER_SURFACE 0
#define CAIRO_HAS_WIN32_SURFACE 1
#define CAIRO_HAS_WIN32_FONT 1

#endif

Close and save cairo-features.h .

Make sure “Solution Configurations” in the toolbar is set to “Debug”.

Right click on “libcairo” in the “Solution Explorer” and go to “Properties”.

Location:Variable:Action:
“Configuration Properties” / “General”“Configuration Type”Change to “Dynamic DLL (.dll)”
“Configuration Properties” / “C/C++” / “Code Generation”“Runtime Library”Change to “Multi-threaded Debug DLL (/MDd)”
“Configuration Properties” / “C/C++” / “General”“Additional Include Directories”Change to “C:/devel/libs/zlib-1.2.3;C:/devel/libs/libpng-1.2.32;C:/devel/libs/pixman-0.12.0/pixman”
“Configuration Properties” / “Linker” / “General”“Additional Include Directories”Change to “C:/devel/libs/zlib-1.2.3/contrib/vstudio/vc8/x86/ZlibDllDebug;C:/devel/libs/libpng-1.2.32/projects/visualc71/Win32_DLL_ASM_Debug;C:/devel/libs/pixman-0.12.0/pixman/debug”
“Configuration Properties” / “Linker” / “Input”“Additional Dependencies”Change to “zlib1.lib libpng13d.lib pixman-1.lib msimg32.lib”
“Configuration Properties” / “Linker” / “General”“Output File”Change to “$(OutDir)/$(ProjectName)d.dll”

Click on “OK” to close the “Properties” box.  Right click on “libcairo” in the “Solution Explorer”, and click on “Build”.

The output files, “libcairod.lib” and “libcairod.dll”, are located at:
“C:/devel/libs/cairo-1.8.0/vs9/libcairo/Debug”
The Cairo include directory is: “C:/devel/libs/cairo-1.8.0/src”.

That’s it.. enjoy! Make sure to visit my wxCairo tutorial!



原文:http://blog.csdn.net/bearjiang/article/details/6329716

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值