stranger gtk thread issue

For a new task from my job, I need write a GTK application. It's fresh new to me. Yes, I have some years experience on Window$ application development. I have almost used everything of MFC in the past. I guess most UI frameworks are similar. MVC, window,

msg, archive, etc. But at least cocoa is quite different to MFC in something "work style". Just look at sample code of GTK, it is also something different to MFC. Whatever, a new domain is always interesting.

 

Back to the subject, I wrote a piece of code from scratch. Today, I want to add thread support for more complicated functions.

But I always got a segment fault on g_thread_init(NULL). And I just use a piece of official code from gnome.org it still fails.

int
main (int argc, char *argv[])
{
  GtkWidget *window;

  g_thread_init (NULL);
  gdk_threads_init ();
  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_show (window);

  gdk_threads_enter ();
  gtk_main ();
  gdk_threads_leave ();

  return 0;
}
 

 

My compile command line is easy too.

 

gcc -o hell hell.c  \
        `pkg-config --cflags --libs gtk+-2.0 gthread`

After many many try and many many failures, I have to look at a large Makefile of another open source software's source code tree. After remove libraries one by one from about thirty libraries, I locate the root cause is --

I need use ghread-2.0 rather than gthread.