[cairo] Getting up and Running with Cairo (OS X)

Carl Worth cworth at cworth.org
Wed Nov 14 10:06:03 PST 2007


On Wed, 14 Nov 2007 16:56:46 +0000, Baz wrote:
>
> Slightly off topic - over on the git mailing list I notice they're
> deprecating `...` in their scripts in favour of $(...); it does the
> same thing in sh, is easier to read, and nests. So something like...
>
> cc -o hello $(pkg-config --cflags --libs cairo)  hello.c

Hehe. Yes, I had just now made exactly this change on the following
page:

	http://cairographics.org/FAQ

Another advantage it has is that it's much less ambiguous for someone
manually transcribing the command, (particularly if they have their
web browser configured with a horrible font).

I also added a bunch of text. Before it said:

	You can compile the above hello.c with:

		cc -o hello `pkg-config --cflags --libs cairo` hello.c

	and, after running the resulting "hello" program you'll have a
 	PNG image file named "hw.png" with "Hello World" written in blue.

Now it says:

	You will need to instruct the compiler where to find the
	cairo.h file, (generally something like "-I
	/usr/include/cairo"), and tell the linker where to find the
	cairo library and to link with it, (often something like "-L
	/usr/lib -lcairo").

	But the exact flags and paths will depend on your compiler and
	your installation of cairo. To simplify this, cairo uses
	pkg-config which can help you determine the correct flags to
	use. If you have pkg-config installed, then you can compile
	the above hello.c with:

		cc -o hello $(pkg-config --cflags --libs cairo) hello.c

	and, after running the resulting "hello" program you'll have a
	PNG image file named "hw.png" with "Hello World" written in
	blue.

	NOTE: If cairo is not installed to a system directory that
	pkg-config is aware of, then you will need to tell pkg-config
	about the directory by setting the "PKG_CONFIG_PATH"
	environment variable to point to the directory into which
	cairo.pc is installed, (for example, with bash, "export
	PKG_CONFIG_PATH=/usr/local/lib/pkgconfig").

Hopefully that will help avoid some confusion. And if anyone has any
further suggestions for improvement, please feel free to recommend
them, (or just change the page---anyone can register an account and
update the cairo web pages).

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20071114/96b1e563/attachment.pgp 


More information about the cairo mailing list