[cairo] The first cairo program complie error

Woenkee Sohn wksohn at gmail.com
Thu Nov 1 16:28:00 PDT 2007


I compiled the minimal cairo program on the cairo web.

There're UNDEFINED REFERENCE errors, thogh I could find those names from libcairo.a

Any ideas ?


Thank you, guys !!!

Woenkee.


hrere is the command line I typed ---------------------------------------------------------------------------------------------------

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



here is the error message -------------------------------------------------------------------------------------------------------------



/cygdrive/c/DOCUME~1/wksohn/LOCALS~1/Temp/ccGmDUgm.o:hello.c:(.text+0x42): undefined reference to `_cairo_image_surface_c
reate'
/cygdrive/c/DOCUME~1/wksohn/LOCALS~1/Temp/ccGmDUgm.o:hello.c:(.text+0x50): undefined reference to `_cairo_create'
/cygdrive/c/DOCUME~1/wksohn/LOCALS~1/Temp/ccGmDUgm.o:hello.c:(.text+0x76): undefined reference to `_cairo_select_font_fac
e'
/cygdrive/c/DOCUME~1/wksohn/LOCALS~1/Temp/ccGmDUgm.o:hello.c:(.text+0x8b): undefined reference to `_cairo_set_font_size'
/cygdrive/c/DOCUME~1/wksohn/LOCALS~1/Temp/ccGmDUgm.o:hello.c:(.text+0xa8): undefined reference to `_cairo_set_source_rgb'

/cygdrive/c/DOCUME~1/wksohn/LOCALS~1/Temp/ccGmDUgm.o:hello.c:(.text+0xc7): undefined reference to `_cairo_move_to'
/cygdrive/c/DOCUME~1/wksohn/LOCALS~1/Temp/ccGmDUgm.o:hello.c:(.text+0xda): undefined reference to `_cairo_show_text'
/cygdrive/c/DOCUME~1/wksohn/LOCALS~1/Temp/ccGmDUgm.o:hello.c:(.text+0xe5): undefined reference to `_cairo_destroy'
/cygdrive/c/DOCUME~1/wksohn/LOCALS~1/Temp/ccGmDUgm.o:hello.c:(.text+0xf8): undefined reference to `_cairo_surface_write_t
o_png'
/cygdrive/c/DOCUME~1/wksohn/LOCALS~1/Temp/ccGmDUgm.o:hello.c:(.text+0x103): undefined reference to `_cairo_surface_destro
y'
collect2: ld returned 1 exit status
[wksohn at ANDYIBM1 ~/oceanside]$ ./compile
/cygdrive/c/DOCUME~1/wksohn/LOCALS~1/Temp/cc2Njy4T.o:hello.c:(.text+0x42): undefined reference to `_cairo_image_surface_c
reate'
/cygdrive/c/DOCUME~1/wksohn/LOCALS~1/Temp/cc2Njy4T.o:hello.c:(.text+0x50): undefined reference to `_cairo_create'
/cygdrive/c/DOCUME~1/wksohn/LOCALS~1/Temp/cc2Njy4T.o:hello.c:(.text+0x76): undefined reference to `_cairo_select_font_fac
e'
/cygdrive/c/DOCUME~1/wksohn/LOCALS~1/Temp/cc2Njy4T.o:hello.c:(.text+0x8b): undefined reference to `_cairo_set_font_size'
/cygdrive/c/DOCUME~1/wksohn/LOCALS~1/Temp/cc2Njy4T.o:hello.c:(.text+0xa8): undefined reference to `_cairo_set_source_rgb'

/cygdrive/c/DOCUME~1/wksohn/LOCALS~1/Temp/cc2Njy4T.o:hello.c:(.text+0xc7): undefined reference to `_cairo_move_to'
/cygdrive/c/DOCUME~1/wksohn/LOCALS~1/Temp/cc2Njy4T.o:hello.c:(.text+0xda): undefined reference to `_cairo_show_text'
/cygdrive/c/DOCUME~1/wksohn/LOCALS~1/Temp/cc2Njy4T.o:hello.c:(.text+0xe5): undefined reference to `_cairo_destroy'
/cygdrive/c/DOCUME~1/wksohn/LOCALS~1/Temp/cc2Njy4T.o:hello.c:(.text+0xf8): undefined reference to `_cairo_surface_write_t
o_png'
/cygdrive/c/DOCUME~1/wksohn/LOCALS~1/Temp/cc2Njy4T.o:hello.c:(.text+0x103): undefined reference to `_cairo_surface_destro
y'
collect2: ld returned 1 exit status




here is the source code from http://cairographics.org/FAQ/#minimal_C_program  ----------------------------------------

#include <cairo.h>

int
main (int argc, char *argv[])
{
        cairo_surface_t *surface;
        cairo_t *cr;

        surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 240, 80);
        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;
}


here is the library search result using nm command -----------------------------------------------------------------------


[wksohn at ANDYIBM1 /usr/local/lib]$ nm libcairo.a | grep cairo_image_surface_create
000006b0 T __cairo_image_surface_create_for_data_with_content
00000060 T __cairo_image_surface_create_for_pixman_image
00000890 t __cairo_image_surface_create_similar
00000580 T __cairo_image_surface_create_with_content
00000140 T __cairo_image_surface_create_with_masks
00000480 T _cairo_image_surface_create
000005c0 T _cairo_image_surface_create_for_data
         U _cairo_image_surface_create
         U _cairo_image_surface_create
         U _cairo_image_surface_create
         U __cairo_image_surface_create_for_pixman_image
         U _cairo_image_surface_create
         U _cairo_image_surface_create
         U __cairo_image_surface_create_with_content
         U _cairo_image_surface_create
         U _cairo_image_surface_create_for_data
00000a90 T _cairo_image_surface_create_from_png
00000b90 T _cairo_image_surface_create_from_png_stream
         U _cairo_image_surface_create_for_data
         U _cairo_image_surface_create
[wksohn at ANDYIBM1 /usr/local/lib]$
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20071101/235a265e/attachment.html 


More information about the cairo mailing list