Re: pthreads + gtk



On Friday 20 September 2002 01:28 am, Chris Wareham wrote:
> NavEcos wrote:
> > First the example "gtk-thread.c" doesn't compile with the command they
> > advertise, but it works with the additional library added "gdk-x11-2.0"
> >
> > $ gcc gtk-thread.c -lgdk-x11-2.0 `gtk-config --cflags --libs gthread`
>
> If you're using GTK 2.0, which it looks like you should be, then the
> command to compile would be:

I appreciate the tip, but then I get the following:

$ gcc thread.cpp `pkg-config --cflags --libs gtk+-2.0` -lpthread

produces

/tmp/ccwLDn5O.o: In function `main':
/tmp/ccwLDn5O.o(.text+0x18c): undefined reference to `g_thread_init'
collect2: ld returned 1 exit status

So what library contains g_thread_init?

if it's informative at all:

$ pkg-config --cflags --libs gtk+-2.0

produces:

-I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 
-I/usr/include/pango-1.0 -I/usr/X11R6/include -I/usr/include/freetype2 
-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -lgtk-x11-2.0 
-lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangox-1.0 -lpangoxft-1.0 
-lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0

My problem is mostly finding complete documentation.  Gnome and gtk
change so blazingly fast, that most of the documentation I find it out
of date.  Several things are "deprecated" with no suggestions as to
what has replaced it.

I.E. I'm a newbie, and the learning curve is steep.

> $ gcc -o gtk-thread gtk-thread.c `pkg-config --cflags --libs gtk+-2.0`
>
> > But it fails with g++
> >
> > $ g++ gtk-thread.cpp -lgdk-x11-2.0 `gtk-config --cflags --libs gthread`
> > thread.c: In function `int main (int, char **)':
> > thread.c:99: `gdk_threads_init' undeclared (first use this function)
> > thread.c:99: (Each undeclared identifier is reported only once for each
> > function it appears in.)
>
> Hmm, the mixing of GTK+ 1.2 and 2.0 is probably causing this problem.
> Try using one or the other, but not both (in other words, gtk-config
> if you're using 1.2, or pkg-config if you're using 2.0).

Probably, but why would 1.2 not contain the gdk_threads_init()
function?  I did a search through all the libraries and only 2.0
contains it, which is why I was forced to use, unless RH 7.3 puts the
library in some bizarre non standard place.

> Chris

Thanks,
-Rich



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