Re: pthreads + gtk
Olexiy Avramchenko wrote: > Use the following: > gcc thread.cpp `pkg-config --cflags --libs gtk+-2.0 gthread` Oops, my fault, use gthread-2.0 instead of gthread: gcc thread.cpp `pkg-config --cflags --libs gtk+-2.0 gthread-2.0` Olexiy ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: pthreads + gtk
NavEcos wrote: > > 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. > The API did change dramatically with version 2.0, but prior to that it hadn't changed for a long, long time. I've got applications I wrote against the 1.1 development series that still compile with 1.2.10. If you're just starting out with GTK+, then the tutorial at http://www.gtk.org/ is well worth a read. As are the FAQ and reference documentation found at the same site. For differences between version 1.2 and 2.0, see the following page: http://developer.gnome.org/doc/API/2.0/gtk/gtk-changes-2-0.html The tutorial and API reference is included in the source tarballs for GTK+ and Glib. I don't know if the standard RedHat RPMs install them anywhere, but if not then they are all on the GTK+ website. Hope this helps, Chris -- [EMAIL PROTECTED] (work) [EMAIL PROTECTED] (home) ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: pthreads + gtk
NavEcos wrote: >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? > Use the following: gcc thread.cpp `pkg-config --cflags --libs gtk+-2.0 gthread` You dont need to include -lpthread. Olexiy ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
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 ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: pthreads + gtk
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: $ 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). Chris -- [EMAIL PROTECTED] (work) [EMAIL PROTECTED] (home) ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: pthreads + gtk
NavEcos wrote: >1) I have some experience with X11 coding, and it looks like I need to send >the GTK equivalent of XSync, but I cannot find it in the documentation. > Hello, gdk_flush() does XSync(, FALSE). Olexiy ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: pthreads + gtk
> 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` Are you really saying that you are mixing gtk-config (from gtk+ 1.2) and Gtk+ 2.0 libraries ? No wonder it doesn't work ;-) > 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.) > > any hints? I've done all my coding in C++ Hint: C++ is a different language than C. Also, we can't guess what gtk-thread.cpp and thread.c look like. Arno ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: pthreads + gtk
On Thursday 19 September 2002 06:09 am, Arnaud Charlet wrote: > > a) surround EVERY*** call to a GDK, GTK or X11 function > > with gdk_threads_{enter,leave} pair > > That's misleading, only calls from a thread other than the thread running > the main loop should call gdk_threads_enter/leave. > > Arno > ___ > gtk-list mailing list > [EMAIL PROTECTED] > http://mail.gnome.org/mailman/listinfo/gtk-list Well, then I have another question regarding threads: 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` 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.) any hints? I've done all my coding in C++ Thanks, -Rich ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: pthreads + gtk
> a) surround EVERY*** call to a GDK, GTK or X11 function > with gdk_threads_{enter,leave} pair That's misleading, only calls from a thread other than the thread running the main loop should call gdk_threads_enter/leave. Arno ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: pthreads + gtk
>I am working on a program that gets data from a socket asynchronously. As a >result, the only way I could figure out to update the display as data came in >was to use pthreads. > >I'm using a clist, and the update isn't immediate, sometimes it takes several >seconds to see the data update onto the screen. Other times, elements become >invisible for some time, although the data is there, just not visible. > >I figure there is 2 possibilities: > >The one I hope it is: > >1) I have some experience with X11 coding, and it looks like I need to send >the GTK equivalent of XSync, but I cannot find it in the documentation. > >The one I'm praying it isn't: > >2) GTK isn't compatible with pthreads. I know X11 isn't re-entrant. If GTK >can't handle asynchronous input, how should I handle asynchronous data input? > >I *could* cache the data in one thread, and then cause an "event" in the >gtk_main () loop to cause the data to be processed.. How do I send an event >from one process to another? 1) read the GTK+ FAQ. of course its compatible with pthreads 2) you have two options when using threads: a) surround EVERY*** call to a GDK, GTK or X11 function with gdk_threads_{enter,leave} pair b) have only one thread make calls to GDK, GTK or X11, and have all other threads send a request to the GUI thread via a pipe. the pipe is "wired into" the GUI main loop by using gtk_input_add() or its glib cousins. 3) search the mailing list archives because there are lots and lots and lots of other messages about this. I vastly prefer 2.b. I have several large scale multithreaded programs that use GTK. --p ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
pthreads + gtk
I am working on a program that gets data from a socket asynchronously. As a result, the only way I could figure out to update the display as data came in was to use pthreads. I'm using a clist, and the update isn't immediate, sometimes it takes several seconds to see the data update onto the screen. Other times, elements become invisible for some time, although the data is there, just not visible. I figure there is 2 possibilities: The one I hope it is: 1) I have some experience with X11 coding, and it looks like I need to send the GTK equivalent of XSync, but I cannot find it in the documentation. The one I'm praying it isn't: 2) GTK isn't compatible with pthreads. I know X11 isn't re-entrant. If GTK can't handle asynchronous input, how should I handle asynchronous data input? I *could* cache the data in one thread, and then cause an "event" in the gtk_main () loop to cause the data to be processed.. How do I send an event from one process to another? Many thanks, -Rich ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list