-
Notifications
You must be signed in to change notification settings - Fork 0
Installation Windows (with MSYS2)
Follow the instructions here - Installation - Windows#1-installing-node-gyp
- Get the latest 64 bit MSYS2 installer from here
- In the MSYS2 shell, install cairo and its dependencies with pacman:
pacman -S mingw64/mingw-w64-x86_64-cairo
and the tools that will be needed to create .lib files for the Visual Studio linker:
pacman -S mingw64/mingw-w64-x86_64-binutils mingw64/mingw-w64-x86_64-tools
- Now you just need to generate .lib files for the DLLs you need to link to. To do that:
/mingw64_shell.bat # gives you a MinGW64 shell
gendef /mingw64/bin/libcairo-2.dll
dlltool -d libcairo-2.def -l /mingw64/lib/libcairo-2.lib
gendef /mingw64/bin/libpng16-16.dll
dlltool -d libpng16-16.def -l /mingw64/lib/libpng16-16.lib
rm libcairo-2.def libpng16-16.def
-
Inside
binding.gyp
from node-canvas's root, the paths to the lib files are hard-coded on the Windows platform. You will have to edit it. ChangeGTK_ROOT
to beC:/msys64/mingw64
, and changepng.lib
to belibpng16-16.lib
andcairo.lib
tolibcairo-2.lib
and then runnode-gyp rebuild
. -
The final step just involves copying all of the DLLs in
/mingw64/bin
into Canvas'sbuild/Release
folder. There are a lot of them, around 20MB worth. You could use Dependency Walker to figure out which ones are really needed, or you can copy them all. After that you're all done!
By hand-editing the binding.gyp
you can get all of the features of node-canvas - full Pango, FreeType and JPEG support even with libjpeg-turbo for super fast compression. You just have to generate the .lib
files as shown above and edit the GYP file's paths, also don't forget to set the with_<lib>
to true at the very top.
MSYS is currently the recommended way to get Pango and the whole GTK stack, so you probably won't get more up-to-date libraries any other way. It is possible but difficult to compile Cairo on Windows, and the Installation - Windows wiki does have less steps but the files are at a fixed, older version