Re: [gtk-list] g_thread_init() problems




rhfreeman <rhfreeman@micron.com> writes:

> Hi all,
> 
> I have the following piece of code in a program of mine....
> 
> if (!g_thread_supported())
>   g_thread_init(NULL);
> 
> ...running on Solaris 2.6 w GTK/GLIB v1.2.6.
> 
> When I try to compile it I get this error:
> 
> Sovereign[259] ~/rwaves>gcc -Wall whatever.c `gtk-config --cflags --libs`
> `gdkmagick-config --libs`
> /var/tmp/ccVtLX4k.o: In function `main':
> /var/tmp/ccVtLX4k.o(.text+0x138e0): undefined reference to `g_thread_init'
> collect2: ld returned 1 exit status
> Sovereign[260] ~/rwaves>

g_thread_init() is in a tiny separate library -lgthread. This
avoids having to link every GLib program against -lpthread.

The invocation for gtk-config you need is:
 
gcc -Wall whatever.c `gtk-config --cflags --libs gthread` `gdkmagick-config --libs`

> And yet if I called g_thread_init() without any arguments it complains
> because there isn't enough arguments to it!

Well, it is in the header file, but not in -lglib.

> PS - If anyone knows anything about using threads with GTK - could they help
> or point me in a direction where I can be helped! I can't find much
> documentation about them anywhere!

The FAQ has a short but pretty complete section on threading.

Regards,
                                        Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]