Page 1 of 1
undefined reference to `g_thread_init'
Posted: Mon Feb 12, 2007 6:52 pm
by Trond
When I try to compile a C/C++ program I get this error:
undefined reference to `g_thread_init'
What can I do to fix this? I have installed libglib1.2-dev and libglib2.0-dev.
Posted: Mon Feb 12, 2007 8:32 pm
by Nik
try to link with pthread. Maybe that solves the problem (CFLAGS+=-lpthread)
don't know though
Posted: Mon Feb 12, 2007 8:50 pm
by KarLKoX
To use g_thread_init() in your program, you have to link with the libraries that the command pkg-config --libs gthread-2.0 outputs. This is not the case for all the other thread related functions of GLib. Those can be used without having to link with the thread libraries.
http://developer.gnome.org/doc/API/2.0/ ... hread-init
Posted: Thu Feb 15, 2007 8:22 pm
by Trond
Thanks both. I added this at the end of the ./configure lines and it did wonders.
Code: Select all
CFLAGS="-pthread -lgthread-2.0 -lglib-2.0"