I bet you tried to link with -lgthead instead of -lgthead-2.0.
gcc `pkg-config --cflags --libs gtk+-2.0 gthread-2.0` -g gtk_test.c
That works fine for me, but the following gives exactly your error;
gcc `pkg-config --cflags --libs gtk+-2.0 gthread` -g gtk_test.c
- Erwin
On Fri, 2006-05-26 at 05:22 -0400, Owen Taylor wrote:
On Thu, 2006-05-25 at 23:58 -0400, Sean wrote:
> With the latest rawhide, the following test program generates
> a segfault; backtrace below. Is this a known problem?
> If not, where should it be reported?
Does it work if you call gtk_init() before gdk_threads_enter()?
I wouldn't consider the code below normal, though I can't
*offhand* think of what problems it would cause.
If not, then install the -debuginfo packages, get a decent backtrace,
then report it either in Red Hat bugzilla or GNOME bugzilla; I
don't think either one is particular more right then the other;
it probably would be an upstream bug, but it's hard to say.
Owen
> Thanks
> Sean
>
> #include <gtk/gtk.h>
> int main (int argc, char *argv[])
> {
> GtkWidget *window;
>
> g_thread_init(NULL);
> gdk_threads_init();
> gdk_threads_enter();
>
> gtk_init(&argc, &argv);
>
> window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
> gtk_widget_show(window);
>
> gtk_main();
> gdk_threads_leave();
>
> return 0;
> }
>
>
> [Thread debugging using libthread_db enabled]
> [New Thread -1208662336 (LWP 20050)]
>
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread -1208662336 (LWP 20050)]
> 0x00acb27e in pthread_mutex_trylock () from /lib/libpthread.so.0
> (gdb) bt
> #0 0x00acb27e in pthread_mutex_trylock () from /lib/libpthread.so.0
> #1 0x00b481cd in g_thread_init () from /usr/lib/libgthread-1.2.so.0
> #2 0x00c97a2f in g_slice_alloc () from /lib/libglib-2.0.so.0
> #3 0x00c741a9 in g_hash_table_new_full () from /lib/libglib-2.0.so.0
> #4 0x00c74228 in g_hash_table_new () from /lib/libglib-2.0.so.0
> #5 0x00c6dc76 in g_quark_from_static_string () from /lib/libglib-2.0.so.0
> #6 0x005016db in g_type_init_with_debug_flags () from /lib/libgobject-2.0.so.0
> #7 0x005018b2 in g_type_init () from /lib/libgobject-2.0.so.0
> #8 0x00124118 in gdk_pre_parse_libgtk_only () from /usr/lib/libgdk-x11-2.0.so.0
> #9 0x0072ae65 in gtk_init_with_args () from /usr/lib/libgtk-x11-2.0.so.0
> #10 0x00c8d66d in g_option_context_parse () from /lib/libglib-2.0.so.0
> #11 0x0072a96c in gtk_parse_args () from /usr/lib/libgtk-x11-2.0.so.0
> #12 0x0072a9e4 in gtk_init_check () from /usr/lib/libgtk-x11-2.0.so.0
> #13 0x0072aa24 in gtk_init () from /usr/lib/libgtk-x11-2.0.so.0
> #14 0x08065229 in main (argc=1, argv=0xbf875344) at qtry.c:11
>