Pages

Tuesday, September 18, 2007

undefined reference to `g_thread_init'

If you get this error message
"undefined reference to `g_thread_init'"
during the compilation of your code, that use GLib.

Solution 1 - Using configure.in
insert the follow code line in your configure.in
AC_CHECK_LIB(gthread-2.0, g_thread_init)

Solution 2 - Compiler command line
add the parameter
-lgthread-2.0
to the compiler.

10 comments:

Anatoly said...

thanks. i've just googled for the solution of above problem

Willie Wu said...

Thanks, this post is really useful.

kkgupta said...

Thanks! You just solved my problem after a single Google search.

Unknown said...

Same as the rest, thanks!

shailesh said...

Thanks A lot..

tArKi said...

Thanks very much!

Hemant said...

I also got this error and solved less than 1 minute.
Thank u so much for giving good suggestion at right time.
By using this example, we can solve similar kind of problem in future.

Hemant said...

I also got this error and solved within 1 minute by seeing this.
With this as a reference, we can solve similar kind of problems in future
Thanks a lot for giving good suggestion at right time.
Kumar HP

rory said...

This rocks. Had just spent the day working around glib version issues, finally found the correct version of glib that let me update some other libs w/o having to rewrite my code, and ran into this.

KenP said...

I am compiling nspluginviewer. I have only "configure" and no "configure.in". Where do I add this check? I get the error during linking and the message is:
/usr/bin/ld: npviewer-npw-viewer.o: undefined reference to symbol 'g_thread_init'

Thanks.