[cairo] Tripping on first step - cannot compile "hello world" with Cairo on Mingwenv
mathog
mathog at caltech.edu
Thu Mar 8 10:13:40 PST 2012
There is some problem when I try to build the simplest possible Cairo
program
in my mingwenv build environment. This uses the devlib pieces from the
Inkscape
project, and those all work OK. A C or C++ "hello world" test
program will build just fine, but not one using cairo.
In C:\progs\testcairo in a Windows XP command line shell:
set DEVLIBS_PATH=c:\progs\devlibs2
set MINGW_PATH=c:\progs\mingw
set MINGW_BIN=%MINGW_PATH%\bin
set PKG_CONFIG_PATH=%DEVLIBS_PATH%\lib\pkgconfig
set PATH=%DEVLIBS_PATH%\bin;%DEVLIBS_PATH%\python;%MINGW_BIN%;%PATH%
Then run the command:
gcc -o test -mms-bitfields -Ic:/progs/devlibs2/include/gtk-2.0
-Ic:/progs/devlibs2/lib/gtk-2.0/include
-Ic:/progs/devlibs2/include/atk-1.0 -Ic:/progs/devlibs2/include/cairo
-Ic:/progs/devlibs2/include/gdk-pixbuf-2.0
-Ic:/progs/devlibs2/include/pango-1.0
-Ic:/progs/devlibs2/include/glib-2.0
-Ic:/progs/devlibs2/lib/glib-2.0/include
-Ic:/progs/devlibs2/include/pixman-1 -Ic:/progs/devlibs2/include
-Ic:/progs/devlibs2/include/freetype2
-Ic:/progs/devlibs2/include/libpng12 -Lc:/progs/devlibs2/lib
-lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgio-2.0 -lpangowin32-1.0
-lgdi32 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lpango-1.0 -lcairo
-lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl test.c
Where everything between "-o test" and "test.c " is the output of:
C:\progs\devlibs2\bin\pkg-config --cflags --libs gtk+-2.0
The test.c program is:
#include <cairo.h>
#include <gtk/gtk.h>
static gboolean
on_expose_event(GtkWidget *widget,
GdkEventExpose *event,
gpointer data)
{
cairo_t *cr;
cr = gdk_cairo_create(widget->window);
cairo_set_source_rgb(cr, 0.1, 0.1, 0.1);
cairo_select_font_face(cr,
"Courier",CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size(cr, 13);
cairo_move_to(cr, 20, 30);
cairo_show_text(cr, "Hello world");
cairo_destroy(cr);
return FALSE;
}
The build fails at the link stage with:
C:\DOCUME~1\david\LOCALS~1\Temp\cc7D0h4h.o:test.c:(.text+0x10):
undefined reference to `gdk_cairo_create'
C:\DOCUME~1\david\LOCALS~1\Temp\cc7D0h4h.o:test.c:(.text+0x54):
undefined reference to `cairo_set_source_rgb'
C:\DOCUME~1\david\LOCALS~1\Temp\cc7D0h4h.o:test.c:(.text+0x77):
undefined reference to `cairo_select_font_face'
C:\DOCUME~1\david\LOCALS~1\Temp\cc7D0h4h.o:test.c:(.text+0x94):
undefined reference to `cairo_set_font_size'
C:\DOCUME~1\david\LOCALS~1\Temp\cc7D0h4h.o:test.c:(.text+0xc3):
undefined reference to `cairo_move_to'
C:\DOCUME~1\david\LOCALS~1\Temp\cc7D0h4h.o:test.c:(.text+0xd6):
undefined reference to `cairo_show_text'
C:\DOCUME~1\david\LOCALS~1\Temp\cc7D0h4h.o:test.c:(.text+0xe1):
undefined reference to `cairo_destroy'
c:/progs/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libmingw32.a(main.o):main.c:(.text+0xd2):
undefined reference to `WinMain at 16'
collect2: ld returned 1 exit status
Tried changing gcc to g++ and test.c to test.cpp, but it came out the
same. The missing references are visible as strings in
libcairo.dll.a, which seems to be on the path specified on the command
line.
Any idea what is going wrong here???
Thank you,
David Mathog
mathog at caltech.edu
Manager, Sequence Analysis Facility, Biology Division, Caltech
More information about the cairo
mailing list