[cairo] Getting up and Running with Cairo (OS X)
cworth at cworth.org
Wed Nov 14 09:40:16 PST 2007
On Wed, 14 Nov 2007 11:55:41 -0000 (UTC), wrote:
> I am running OS X (Leopard) and I have installed Cairo via MacPorts, and
> indeed MacPorts reports Cairo is installed:
Welcome to the world of using cairo.
> I am trying to compile a very simple app just to check everything is
> working, and have used the following command:
> cc -o hello -L/opt/local/lib -I/opt/local/include/cairo hello.c
> To compile the 'minimal C program' from
It looks like we need to improve the instructions on that web
page. You're missing the following from your compilation flags:
to instruct the linker to link with the cairo library.
> I am wanting to use Cairo just to export SVG documents (created inside my
> app) to PNG or similar raster format. I am not wanting to display them
> live to the user at this stage, just output to disk (so I believe I don't
> need Quartz support?).
Right. You should be able to target cairo's image surface just fine
for that, (meaning you won't require targeting a cairo-quartz
> Am I right that I should be able to get this working fairly easily under
> OS X?
The cairo pieces should be quite easy to get working. Do note,
however, that cairo alone doesn't give you any support for *parsing*
and SVG file.
Fortunately, there is a library, librsvg, that does parse SVG files
and renders them through cairo to any cairo surface. An example C
program using librsvg and cairo can be found here:
However, since you're actually generating the SVG content within your
program, it's possible that the intermediate, textual XML content
isn't necessary at all. That is, having your code emit XML, and
then using librsvg to parse that XML and call into cairo functions
would just be over-complicating things, (particularly if you didn't
also need the content as an actual SVG file).
If that's the case, it will likely be much easier for you to have your
program make calls into cairo functions rather than emitting XML.
> Any insight into the above compile problem will make my day,
I hope the above helps. Do let us know if you need anything else. And
have fun with cairo!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20071114/ee4c66aa/attachment.pgp
More information about the cairo