-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Installation: Mac OS X
There are several methods to install cairo on OSX, including mac ports, homebrew, and building from source. We will be installing from source, because this is what I prefer to do, as package managers are often out of date. These commands (or similar) are available on most systems, so these instructions will work on many other platforms as well.
Check for pkg-config via $ which pkg-config
, if not found you will want to install it:
$ curl https://pkg-config.freedesktop.org/releases/pkg-config-0.28.tar.gz -o pkgconfig.tgz
$ tar -zxf pkgconfig.tgz && cd pkg-config-0.28
$ ./configure && make install
If you run into an error like the following:
configure: error: Either a previously installed pkg-config or "glib-2.0 >= 2.16" could not be found. Please set GLIB_CFLAGS and GLIB_LIBS to the correct values or pass --with-internal-glib to configure to use the bundled copy.
run ./configure --with-internal-glib && make install
The first thing we need to do is install pixman, the pixel manipulation dependency of cairo.
$ curl -L http://www.cairographics.org/releases/pixman-0.30.0.tar.gz -o pixman.tar.gz
$ tar -zxf pixman.tar.gz && cd pixman-0.30.0/
$ ./configure --prefix=/usr/local --disable-dependency-tracking
$ make install
If you encounter the following error:
pixman-mmx.c:100:20: error: constraint 'K' expects an integer constant
expression
: "y" (__A), "K" (__N)
Use release >=0.34.0 instead:
$ curl -L http://www.cairographics.org/releases/pixman-0.34.0.tar.gz -o pixman.tar.gz
$ tar -zxf pixman.tar.gz && cd pixman-0.34.0/
Now we can install cairo itself in a similar manner:
$ curl -L http://www.cairographics.org/releases/cairo-1.12.18.tar.xz -o cairo.tar.xz
$ tar -xf cairo.tar.xz && cd cairo-1.12.18
$ ./configure --prefix=/usr/local --disable-dependency-tracking
$ make install
A bug with cairo-1.14.2
can result in incorrect text sizing when rendering on OS X Yosemite.
If libpng fails and you get the error "error: recommended PNG functions feature could not be enabled", try installing this binary and re-running the configure step.
If you get the error "error: mandatory image surface backend feature could not be enabled", or "Package cairo was not found in the pkg-config search path.", the following command may resolve it:
$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
If you see "Package 'xcb-shm', required by 'cairo', not found", you probably installed Cairo with homebrew and need to do this:
$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig
$ npm install canvas
or from source:
$ node-gyp rebuild
If you're seeing either one of these errors:
Error: error while reading from input stream
Error: Image given has not completed loaded
Error: node-canvas was built without GIF support
on OS X then you're probably missing giflib and/or libjpeg. Install it with homebrew via:
brew install giflib # for .gif files
brew install libjpeg # for .jpg files
Then recompile node-canvas.