Help with programming using libcairo

Kevin O'Gorman kogorman at gmail.com
Fri May 17 15:15:36 UTC 2013


On Thu, May 16, 2013 at 2:50 PM, Tony Arnold
<tony.arnold at manchester.ac.uk>wrote:

> Kevin,
>
> On 16/05/13 22:35, Kevin O'Gorman wrote:
> > I'm trying to work with the tutorial at
> http://cairographics.org/tutorial/
> > but cannot get anything to compile and link.
> >
> > I entered their first example, and all of the cairo_* symbols show up
> > undefined in the link phase.
> >
> > I'm compiling the tutorial's simplest example, a hello.c program, using
> > gcc `pkg-config --cflags --libs cairo`  -static hello.c -o hello
> >
> > and it looks like the library's empty.  However, when I use nm(1) on
> > /usr/lib/i386-linux-gnu/cairo.so
> > I see those symbols. The nm utility does not seem to work on the .so
> > library, even after following symlinks.
> >
> > pkg-config --libs cairo
> > just emits "-lcairo"
> >
> > I've tried inserting -L /usr/lib/i36-linux-gnu/ to no avail.
> >
> > I'm not sure what else to try.
>
> Can you post your example program somewhere?
>
> Regards,
> Tony.
>
>
No need for a somewhere, it's so short.  It's from the tutorial

#include <cairo.h>

int
main (int argc, char *argv[])
{
        cairo_surface_t *surface =
            cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 240, 80);
        cairo_t *cr =
            cairo_create (surface);

        cairo_select_font_face (cr, "serif", CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_BOLD);
        cairo_set_font_size (cr, 32.0);
        cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
        cairo_move_to (cr, 10.0, 50.0);
        cairo_show_text (cr, "Hello, world");

        cairo_destroy (cr);
        cairo_surface_write_to_png (surface, "hello.png");
        cairo_surface_destroy (surface);
        return 0;
}

It compiles okay to a .o file.  I can't figure out how to link it.

If it matters, I'm running Xubuntu 12.04, with all the relevant development
packages.

-- 
Kevin O'Gorman

programmer, n. an organism that transmutes caffeine into software.
Please consider the environment before printing this email.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20130517/c9c17848/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 441 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20130517/c9c17848/attachment.gif>


More information about the ubuntu-users mailing list