stranger gtk thread issue

sangshuduo posted @ 2008年8月14日 00:01 in GTK with tags GTK linux thread , 1090 阅读

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.

Avatar_small
will writer near me 说:
2020年6月23日 04:44

Thank you again for all the knowledge you distribute,Good post. I was very interested in the article, it's quite inspiring I should admit. I like visiting you site since I always come across interesting articles like this one.Great Job, I greatly appreciate that.Do Keep sharing!

Avatar_small
rough interracial se 说:
2020年7月13日 23:03

Thanks for sharing nice information with us. i like your post and all you share with us is uptodate and quite informative. i would like to bookmark the page so i can come here again to read you. as you have done a wonderful job.

Avatar_small
Gordijnen op maat 说:
2020年7月16日 00:14

Thanks for every other informative site. The place else may just I get that kind of information written in such an ideal means? I have a venture that I’m just now operating on, and I have been on the look out for such information.

Avatar_small
Property management 说:
2020年7月16日 08:24

Hi, I find reading this article a joy. It is extremely helpful and interesting and very much looking forward to reading more of your work.

Avatar_small
Electrical contracto 说:
2020年7月16日 08:24

Exceptionally decent blog and articles. I am realy extremely glad to visit your blog. Presently I am discovered which I really need. I check your blog ordinary and attempt to take in something from your blog. Much obliged to you and sitting tight for your new post.

Avatar_small
mobile app developer 说:
2020年7月17日 17:05

Thank you for the great article I did enjoyed reading it, I will be sure to bookmark your blog and definitely will come back from again. I want to encourage that you continue your great job.

Avatar_small
Buy Instagram likes 说:
2020年7月25日 11:31

This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. Buy Instagram likes

Avatar_small
Buy Instagram likes 说:
2020年8月19日 04:40

This particular papers fabulous, and My spouse and i enjoy each of the perform that you have placed into this. I’m sure that you will be making a really useful place. I has been additionally pleased.

Avatar_small
Pak24tv 说:
2020年12月06日 23:31

I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept. Thank you for the post. what is vpn periodic table voided check

Avatar_small
Robinjack 说:
2020年12月28日 02:02

I like what you guys are up too. Such clever work and reporting! Keep up the superb works guys I have incorporated you guys to my blogroll. I think it will improve the value of my website . software project management

Avatar_small
Vape Tips and Guide 说:
2021年1月27日 01:26

This is again a helpful post. I always read your all posts and always wait for your next posts, but i didn't find any bug in this.

Avatar_small
Robinjack 说:
2021年2月17日 19:57

If only my personal content articles appeared as if this particular! That’s a enhance, btw?-I ‘m new to blog publishing as well as reading numerous blogs helps me out with my very own. Any info you could throw my way to help is very appreciated. Thanks for the great info on this particular post! mini drone with camera

Avatar_small
Nairobi raha 说:
2021年2月22日 18:40

What a fantabulous post this has been. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these. Thank you very much. gridsome body class Hey what a brilliant post I have come across and believe me I have been searching out for this similar kind of post for past a week and hardly came across this. Thank you very much and will look for more postings from you. body fitted grid It was wondering if I could use this write-up on my other website, I will link it back to your website though.Great Thanks. crystal body grid Great article Lot's of information to Read...Great Man Keep Posting and update to People..Thanks gridsome body class Thanks For sharing this Superb article.I use this Article to show my assignment in college.it is useful For me Great Work. body fitted grid

Avatar_small
amelia 说:
2021年3月13日 00:08

Somebody Sometimes with visits your online journal frequently and prescribed it I would say to peruse too. The method for composing is brilliant furthermore the substance is first class. A debt of gratitude is in order for that understanding you give the perusers!  Buy 4 AcO DMT

Avatar_small
amelia 说:
2021年3月15日 00:32

I truly like you're composing style, incredible data, thankyou for posting.  wholesale jewelry suppliers

Avatar_small
amelia 说:
2021年3月18日 19:30

I am happy you take pride in what you compose. This makes you stand way out from numerous different scholars that push ineffectively composed substance.  wholesale bags

Avatar_small
amelia 说:
2021年3月18日 19:30

it was a magnificent opportunity to visit this sort of site and I am glad to know. much obliged to you such a great amount for allowing us to have this open door..  wholesale hair accessories

Avatar_small
chalsea 说:
2021年4月15日 01:30

I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept. Thank you for the post. scopes

Avatar_small
chalsea 说:
2021年4月15日 01:30

Hey, I discover perusing this article a delight. It is greatly useful and intriguing and all that much anticipating perusing a greater amount of your work..  heavy jets


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter