Help with programming using libcairo
Kevin O'Gorman
kogorman at gmail.com
Mon May 20 04:24:05 UTC 2013
Well, color me embarrassed. That was simple, and it worked, and I even
knew why as soon as I read it. I didn't need -png, though. The -static
was just one of my attempts to figure this out.
On Sat, May 18, 2013 at 5:29 PM, Tony Arnold
<tony.arnold at manchester.ac.uk>wrote:
> Kevin,
>
> On 17/05/13 16:15, Kevin O'Gorman wrote:
> > On Thu, May 16, 2013 at 2:50 PM, Tony Arnold
> > <tony.arnold at manchester.ac.uk <mailto: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.
>
> Sorry for delay in replying. Answer is simple. Put the name of the
> source file before the pkg-config bit opf your command, i.e.,
>
> gcc hello.c `pkg-config --cflags --libs cairo-png` -o hello
>
> I also changed '--libs cairo' to '--libs cairo-png'. Not sure if that is
> really needed.
>
> Also remove the -static option.
>
> HTH.
>
> Regards,
> Tony.
> --
> Tony Arnold, Tel: +44 (0) 161 275 6093
> Head of IT Security, Fax: +44 (0) 705 344 3082
> University of Manchester, Mob: +44 (0) 773 330 0039
> Manchester M13 9PL. Email: tony.arnold at manchester.ac.uk
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>
--
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/20130519/bbd8c898/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/20130519/bbd8c898/attachment.gif>
More information about the ubuntu-users
mailing list