• Stars
    star
    196
  • Rank 198,553 (Top 4 %)
  • Language
    Shell
  • License
    The Unlicense
  • Created over 7 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Standalone Cairo DLLs for Windows

This repository is meant to help create Cairo DLLs for Windows. Both 32-bit and 64-bit versions can be built. The resulting cairo.dll file is fully self-contained and does not depend on any other third-party DLLs. FreeType support is included. See this blog post for more information.

Binary releases are available here.

Build Steps

The build-cairo-windows.sh shell script will download, extract, and build all the necessary libraries to link a self-contained cairo.dll with FreeType support. It uses the existing build pipelines of each library as much as possible. It was adapted from https://www.cairographics.org/end_to_end_build_for_win32/

The Visual Studio 2017 compiler is used. Either MSYS, MSYS2 or Cygwin must be used to drive the build environment. So far it has only been tested with MSYS2. If using MSYS2, you'll need to install tar and make first:

$ pacman -S tar make

Building 32-bit

You'll need to create an MSYS2 (for example) shell that has all the correct environment variables set for Visual Studio 2017, including INCLUDE, LIB and PATH.

As of this writing, this can be achieved by opening "x86 Native Tools Command Prompt for VS 2017" from the start menu, and entering commands similar to the following. The final command runs the build-cairo-windows.sh script.

(from an x86 Native Tools Command Prompt for VS 2017)
> set PATH=C:\msys64;%PATH%
> msys2_shell.cmd -use-full-path
$ unset TMP
$ unset TEMP
$ ./build-cairo-windows.sh

Some notes:

  • msys2_shell.cmd -use-full-path opens an MSYS2 terminal while inheriting the PATH from the x86 Native Tools Command Prompt.
  • unset TMP and unset TEMP are currently needed to avoid error MSB6001: Invalid command line switch for "CL.exe". Item has already been added. Key in dictionary: 'TMP' Key being added: 'tmp', which is caused by the MSYS2 environment block having multiple TMP entries due to case sensitivty.

When it's done, you'll find a self-contained package in a subdirectory named output/cairo-windows-x.x.x.

Building 64-bit

  1. First build 32-bit.
  2. Open libpng\projects\vstudio\vstudio.sln in Visual Studio, then add the "x64" platform to the solution as follows:
    • Build โ†’ Configuration Manager
    • Active solution platform: โ†’ <New...>
    • Select x64, click OK, close the Configuration Manager
    • File โ†’ Save All
  3. Perform similar steps as for 32-bit, but open an "x64 Native Tools Command Prompt for VS 2017" instead, and pass x64 as an argument to the script:
(from an x64 Native Tools Command Prompt for VS 2017)
> set PATH=C:\msys64;%PATH%
> msys2_shell.cmd -use-full-path
$ unset TMP
$ unset TEMP
$ ./build-cairo-windows.sh x64

Updating dependencies

The repo contains a deps.yml which can update cairo, freetype etc using dependencies.io

To run this locally, install the commandline tool from https://deps.app/local/

$ curl https://deps.app/install.sh | bash -s -- -b $HOME/bin

Then run it, accepting all the prompts:

$ yes | deps run