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, pixman | http://cairographics.org/releases/ |
libpng | http://www.libpng.org/pub/png/libpng.html |
zlib | http://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
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″.
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″.
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”.
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