{"id":3651,"date":"2014-10-05T00:28:12","date_gmt":"2014-10-05T00:28:12","guid":{"rendered":"http:\/\/www.readytext.co.uk\/?p=3651"},"modified":"2014-10-06T19:30:06","modified_gmt":"2014-10-06T19:30:06","slug":"building-cairo-1-12-16-as-a-lib-on-windows-using-visual-studio","status":"publish","type":"post","link":"https:\/\/www.readytext.co.uk\/?p=3651","title":{"rendered":"Building Cairo 1.12.16 as a .lib on Windows using Visual Studio"},"content":{"rendered":"<p><H1>A real gotcha! (well, it got me)<\/H1><\/p>\n<p>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: <code>HAVE_FT_LOAD_SFNT_TABLE<\/code>. This is important if you are using FreeType: Without setting <code>HAVE_FT_LOAD_SFNT_TABLE<\/code> Cairo uses a &#8220;fallback&#8221; process for embedding fonts, which is not ideal.<\/p>\n<h2>The C source files for a Windows build<\/h2>\n<p>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 <code><a href=\"http:\/\/cairographics.org\/visualstudio\/\">cairo-features.h<\/a><\/code>.<\/p>\n<h2>Preprocessor definitions<\/h2>\n<p>I used the following:<\/p>\n<p><code>WIN32<br \/>\n_DEBUG<br \/>\n_LIB<br \/>\nCAIRO_WIN32_STATIC_BUILD<br \/>\nCAIRO_HAS_FT_FONT<br \/>\nHAVE_FT_LOAD_SFNT_TABLE<\/code><\/p>\n<h2>Other libraries you will need (I do recommend using FreeType)<\/H2><br \/>\n<code>FreeType<br \/>\nPixman<br \/>\nlibpng<br \/>\nZLib<\/code><\/p>\n<h2>List of C source files required (for a cut-down build)<\/h2>\n<p><code>cairo-analysis-surface.c<br \/>\ncairo-arc.c<br \/>\ncairo-array.c<br \/>\ncairo-atomic.c<br \/>\ncairo-base64-stream.c<br \/>\ncairo-base85-stream.c<br \/>\ncairo-bentley-ottmann-rectangular.c<br \/>\ncairo-bentley-ottmann-rectilinear.c<br \/>\ncairo-bentley-ottmann.c<br \/>\ncairo-botor-scan-converter.c<br \/>\ncairo-boxes-intersect.c<br \/>\ncairo-boxes.c<br \/>\ncairo-cache.c<br \/>\ncairo-cff-subset.c<br \/>\ncairo-clip-boxes.c<br \/>\ncairo-clip-polygon.c<br \/>\ncairo-clip-region.c<br \/>\ncairo-clip-surface.c<br \/>\ncairo-clip-tor-scan-converter.c<br \/>\ncairo-clip.c<br \/>\ncairo-color.c<br \/>\ncairo-composite-rectangles.c<br \/>\ncairo-compositor.c<br \/>\ncairo-contour.c<br \/>\ncairo-damage.c<br \/>\ncairo-debug.c<br \/>\ncairo-default-context.c<br \/>\ncairo-deflate-stream.c<br \/>\ncairo-device.c<br \/>\ncairo-error.c<br \/>\ncairo-fallback-compositor.c<br \/>\ncairo-fixed.c<br \/>\ncairo-font-face-twin-data.c<br \/>\ncairo-font-face-twin.c<br \/>\ncairo-font-face.c<br \/>\ncairo-font-options.c<br \/>\ncairo-freed-pool.c<br \/>\ncairo-freelist.c<br \/>\ncairo-ft-font.c<br \/>\ncairo-gstate.c<br \/>\ncairo-hash.c<br \/>\ncairo-hull.c<br \/>\ncairo-image-compositor.c<br \/>\ncairo-image-info.c<br \/>\ncairo-image-source.c<br \/>\ncairo-image-surface.c<br \/>\ncairo-lzw.c<br \/>\ncairo-mask-compositor.c<br \/>\ncairo-matrix.c<br \/>\ncairo-mempool.c<br \/>\ncairo-mesh-pattern-rasterizer.c<br \/>\ncairo-misc.c<br \/>\ncairo-mono-scan-converter.c<br \/>\ncairo-mutex.c<br \/>\ncairo-no-compositor.c<br \/>\ncairo-observer.c<br \/>\ncairo-output-stream.c<br \/>\ncairo-paginated-surface.c<br \/>\ncairo-path-bounds.c<br \/>\ncairo-path-fill.c<br \/>\ncairo-path-fixed.c<br \/>\ncairo-path-in-fill.c<br \/>\ncairo-path-stroke-boxes.c<br \/>\ncairo-path-stroke-polygon.c<br \/>\ncairo-path-stroke-traps.c<br \/>\ncairo-path-stroke-tristrip.c<br \/>\ncairo-path-stroke.c<br \/>\ncairo-path.c<br \/>\ncairo-pattern.c<br \/>\ncairo-pdf-operators.c<br \/>\ncairo-pdf-shading.c<br \/>\ncairo-pdf-surface.c<br \/>\ncairo-pen.c<br \/>\ncairo-png.c<br \/>\ncairo-polygon-intersect.c<br \/>\ncairo-polygon-reduce.c<br \/>\ncairo-polygon.c<br \/>\ncairo-ps-surface.c<br \/>\ncairo-raster-source-pattern.c<br \/>\ncairo-recording-surface.c<br \/>\ncairo-rectangle.c<br \/>\ncairo-rectangular-scan-converter.c<br \/>\ncairo-region.c<br \/>\ncairo-rtree.c<br \/>\ncairo-scaled-font-subsets.c<br \/>\ncairo-scaled-font.c<br \/>\ncairo-script-surface.c<br \/>\ncairo-shape-mask-compositor.c<br \/>\ncairo-slope.c<br \/>\ncairo-spans-compositor.c<br \/>\ncairo-spans.c<br \/>\ncairo-spline.c<br \/>\ncairo-stroke-dash.c<br \/>\ncairo-stroke-style.c<br \/>\ncairo-surface-clipper.c<br \/>\ncairo-surface-fallback.c<br \/>\ncairo-surface-observer.c<br \/>\ncairo-surface-offset.c<br \/>\ncairo-surface-snapshot.c<br \/>\ncairo-surface-subsurface.c<br \/>\ncairo-surface-wrapper.c<br \/>\ncairo-surface.c<br \/>\ncairo-svg-surface.c<br \/>\ncairo-time.c<br \/>\ncairo-tor-scan-converter.c<br \/>\ncairo-tor22-scan-converter.c<br \/>\ncairo-toy-font-face.c<br \/>\ncairo-traps-compositor.c<br \/>\ncairo-traps.c<br \/>\ncairo-tristrip.c<br \/>\ncairo-truetype-subset.c<br \/>\ncairo-type1-fallback.c<br \/>\ncairo-type1-glyph-names.c<br \/>\ncairo-type1-subset.c<br \/>\ncairo-type3-glyph-surface.c<br \/>\ncairo-unicode.c<br \/>\ncairo-user-font.c<br \/>\ncairo-version.c<br \/>\ncairo-wideint.c<br \/>\ncairo-win32-debug.c<br \/>\ncairo-win32-device.c<br \/>\ncairo-win32-display-surface.c<br \/>\ncairo-win32-font.c<br \/>\ncairo-win32-gdi-compositor.c<br \/>\ncairo-win32-printing-surface.c<br \/>\ncairo-win32-surface.c<br \/>\ncairo-win32-system.c<br \/>\ncairo.c<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[],"class_list":["post-3651","post","type-post","status-publish","format-standard","hentry","category-c-programming-miscellaneous"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3651","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3651"}],"version-history":[{"count":7,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3651\/revisions"}],"predecessor-version":[{"id":3670,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3651\/revisions\/3670"}],"wp:attachment":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}