[cairo] Universal Framework for Mac OS X
andreas.krinke at gmx.de
Mon Mar 23 15:35:56 PDT 2009
>> I will post the details of the framework creation if there is interest.
> Sure, please do so. We might find some helpful hints for the gtk-osx
That's the way I did it:
At first, I installed the svn version of MacPorts using the howto at 
(after the heading "Making universal work for 10.4"). Maybe version
1.7.0 has full support for universal builds, so there might be no need
to use the svn version.
These are the steps:
$ svn co http://svn.macports.org/repository/macports/trunk/base MacPorts-svn
$ cd MacPorts-svn
$ export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11/bin
$ sudo mkdir /Library/Tcl/macports-universal-10.4
$ ./configure --prefix=/opt/local-universal-10.4
$ sudo make install
$ sudo vi /opt/local-universal-10.4/etc/macports/variants.conf
I this file, I added the line "+universal +no_x11 +quartz".
Later, this builds cairo without the x11 dependency and with quartz as
$ sudo /opt/local-universal-10.4/bin/port sync
("sync", not "selfupdate", or you will get downgraded)
$ sudo vi /opt/local-universal-10.4/etc/macports/sources.conf
In this file I added file:///Users/ak/MacPorts/ports/ above the rsync
line. We can make copies of the PortFiles of libpixman, libpng and cairo
and change them there.
$ mkdir -p ~/MacPorts/ports/graphics
$ cp -R
libpng cairo} ~/MacPorts/ports/graphics/
Then I changed the Portfiles of the three libraries to alter their
install_name. MacPorts sets it to the absolute path, but we need paths
relative to the executable inside the application bundle. The only way I
found to alter the path was to change the libtool script.
In cairo's Portfile (~/MacPorts/ports/graphics/cairo/Portfile) add the
In libpixman's Portfile add:
And in libpng's Portfile add:
Now it's time to update the portindex:
$ sudo /opt/local-universl-10.4/bin/portindex ~/MacPorts/ports
Install cairo and its dependencies via MacPorts:
$ sudo /opt/local-universl-10.4/bin/port install cairo
This should build libpixman, libpng and cairo.
All we have to do is to create the framework:
$ mkdir Cairo.framework
$ cd Cairo.framework
$ mkdir Headers
$ mkdir Libraries
$ mkdir Resources
Copy the libraries libcairo.2.dylib, libpixman-126.96.36.199.dylib and
libpng12.0.dylib from /opt/local-universal-10.4/lib/ to the Libraries
Copy all the header files to the Headers directory. The headers are
located at /opt/local-universal-10.4/include/cairo/ and .../pixman-1.
This is the list:
Then, I copied the Info.plist file from the cairo framework from the
gtk-osx project  to the Resources directory. Don't forget to change
the version numbers in the file.
Last but not least, create a symlink to the cairo library:
$ ln -s Libraries/libcairo.2.dylib Cairo
That's it. Now you should have an universal framework of cairo including
Well, now I'm tired of typing :D
I know, this seems very complicated. I took ages to find all the little
Don't forget the custom linker flags (see my original post) if you link
against the framework.
More information about the cairo