STM publishing: tools, technologies and change A WordPress site for STM Publishing

5Oct/14Off

Building Cairo 1.12.16 as a .lib on Windows using Visual Studio

A real gotcha! (well, it got me)

I recently built Cairo 1.12.16 as a Windows .lib file using Visual Studio. Somewhat of a painful process but it seems to work fine. One detail that caught me out (and took hours to track down) was that I did not set a critically important preprocessor setting: HAVE_FT_LOAD_SFNT_TABLE. This is important if you are using FreeType: Without setting HAVE_FT_LOAD_SFNT_TABLE Cairo uses a "fallback" process for embedding fonts, which is not ideal.

The C source files for a Windows build

Through trial-and-error I eventually reduced the C files I needed to the list below. So, the .lib file I built is a slightly cut-down build of Cairo but so far it seems to work OK, at least for what I need. You will also need to manually create a header file called cairo-features.h.

Preprocessor definitions

I used the following:

WIN32
_DEBUG
_LIB
CAIRO_WIN32_STATIC_BUILD
CAIRO_HAS_FT_FONT
HAVE_FT_LOAD_SFNT_TABLE

Other libraries you will need (I do recommend using FreeType)


FreeType
Pixman
libpng
ZLib

List of C source files required (for a cut-down build)

cairo-analysis-surface.c
cairo-arc.c
cairo-array.c
cairo-atomic.c
cairo-base64-stream.c
cairo-base85-stream.c
cairo-bentley-ottmann-rectangular.c
cairo-bentley-ottmann-rectilinear.c
cairo-bentley-ottmann.c
cairo-botor-scan-converter.c
cairo-boxes-intersect.c
cairo-boxes.c
cairo-cache.c
cairo-cff-subset.c
cairo-clip-boxes.c
cairo-clip-polygon.c
cairo-clip-region.c
cairo-clip-surface.c
cairo-clip-tor-scan-converter.c
cairo-clip.c
cairo-color.c
cairo-composite-rectangles.c
cairo-compositor.c
cairo-contour.c
cairo-damage.c
cairo-debug.c
cairo-default-context.c
cairo-deflate-stream.c
cairo-device.c
cairo-error.c
cairo-fallback-compositor.c
cairo-fixed.c
cairo-font-face-twin-data.c
cairo-font-face-twin.c
cairo-font-face.c
cairo-font-options.c
cairo-freed-pool.c
cairo-freelist.c
cairo-ft-font.c
cairo-gstate.c
cairo-hash.c
cairo-hull.c
cairo-image-compositor.c
cairo-image-info.c
cairo-image-source.c
cairo-image-surface.c
cairo-lzw.c
cairo-mask-compositor.c
cairo-matrix.c
cairo-mempool.c
cairo-mesh-pattern-rasterizer.c
cairo-misc.c
cairo-mono-scan-converter.c
cairo-mutex.c
cairo-no-compositor.c
cairo-observer.c
cairo-output-stream.c
cairo-paginated-surface.c
cairo-path-bounds.c
cairo-path-fill.c
cairo-path-fixed.c
cairo-path-in-fill.c
cairo-path-stroke-boxes.c
cairo-path-stroke-polygon.c
cairo-path-stroke-traps.c
cairo-path-stroke-tristrip.c
cairo-path-stroke.c
cairo-path.c
cairo-pattern.c
cairo-pdf-operators.c
cairo-pdf-shading.c
cairo-pdf-surface.c
cairo-pen.c
cairo-png.c
cairo-polygon-intersect.c
cairo-polygon-reduce.c
cairo-polygon.c
cairo-ps-surface.c
cairo-raster-source-pattern.c
cairo-recording-surface.c
cairo-rectangle.c
cairo-rectangular-scan-converter.c
cairo-region.c
cairo-rtree.c
cairo-scaled-font-subsets.c
cairo-scaled-font.c
cairo-script-surface.c
cairo-shape-mask-compositor.c
cairo-slope.c
cairo-spans-compositor.c
cairo-spans.c
cairo-spline.c
cairo-stroke-dash.c
cairo-stroke-style.c
cairo-surface-clipper.c
cairo-surface-fallback.c
cairo-surface-observer.c
cairo-surface-offset.c
cairo-surface-snapshot.c
cairo-surface-subsurface.c
cairo-surface-wrapper.c
cairo-surface.c
cairo-svg-surface.c
cairo-time.c
cairo-tor-scan-converter.c
cairo-tor22-scan-converter.c
cairo-toy-font-face.c
cairo-traps-compositor.c
cairo-traps.c
cairo-tristrip.c
cairo-truetype-subset.c
cairo-type1-fallback.c
cairo-type1-glyph-names.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-debug.c
cairo-win32-device.c
cairo-win32-display-surface.c
cairo-win32-font.c
cairo-win32-gdi-compositor.c
cairo-win32-printing-surface.c
cairo-win32-surface.c
cairo-win32-system.c
cairo.c

Comments (0) Trackbacks (0)

Sorry, the comment form is closed at this time.

Trackbacks are disabled.