Pages

Wednesday, August 29, 2007

GLib-GObject-CRITICAL **: g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)' failed

GLib message error:

---

(process:4016): GLib-GObject-CRITICAL **: gtype.c:2240: initialization assertion failed, use IA__g_type_init() prior to this function

(process:4016): GLib-GObject-CRITICAL **: g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)' failed


A possible resolution for this error is to insert the method "g_type_init()" in your main source code, as below.


----
gint
main (gint argc, gchar *argv[])
{
FooExample *foo;

g_type_init();

foo = g_object_new(FOO_TYPE_EXAMPLE, NULL);

g_message("Great success !!\n");

return 0;
}

---
This example is to a simple GLib code, you will use gtk_init() to a GTK code.

No comments: