undefined reference to `g_thread_init'

For everything that's not in any way related to PureBasic. General chat etc...
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

undefined reference to `g_thread_init'

Post 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.
Nik
Addict
Addict
Posts: 1017
Joined: Fri May 13, 2005 11:45 pm
Location: Germany
Contact:

Post by Nik »

try to link with pthread. Maybe that solves the problem (CFLAGS+=-lpthread)
don't know though
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post 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
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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"
Post Reply