After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 97553 - -pthread flag and no libpthread
-pthread flag and no libpthread
Status: RESOLVED NOTABUG
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2002-11-03 12:59 UTC by Dmitry G. Mastrukov
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Dmitry G. Mastrukov 2002-11-03 12:59:07 UTC
CVS HEAD branch first try to use -pthread flag when detecting threading
flags and libs. I consulted with gcc doc and seems -pthread has a reason
only on IBM RS6000 and PowerPC. 
Anyway, built with -pthread flag libgthread has no reference to libpthread.
It causes "unresolved reference" error on building (configuring) packets
with thread support.
glib-2-0 branch has different detecting mechanics and works ok.
Comment 1 Owen Taylor 2002-11-03 16:31:46 UTC
Are you sure about the gcc-3.2? gcc-3.2 definitely does support
-pthread on i386/Linux.

I think you might actually be looking at a bug with older versions 
of pkg-config, especially if GLib builds correctly and you
just have problems with packages that use gthread.


Comment 2 Dmitry G. Mastrukov 2002-11-03 22:01:19 UTC
Yes, I have gcc-3.2 and saw for doc for -pthread in src dir. I don't
know gcc internals I only know what does doc tell me about -pthread.
My system is built from sources so I definitely know versions of
installed packages.
I have pkgconfig-0.12, but problem is not in pkgconfig. ldd on cvs
head does not show me libpthread, but ldd on cvs glib-2-0 shows.
glib-2-0 branch explicitly use -lpthread flag but head relies upon
-pthread.
 
Comment 3 Owen Taylor 2002-11-03 22:51:21 UTC
Let's back up:

 - What package failed to compile with GLib HEAD?
 - What was the error message you got with that package?
Comment 4 Dmitry G. Mastrukov 2002-11-04 07:53:57 UTC
ORBit HEAD failed to configure.

--- config.log
configure:9828: gcc -o conftest -O2 -march=athlon   conftest.c    
-Wl,--export-dynamic  -L/usr/local/gnome2/lib -llinc -lgthread-2.0
-lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0    >&5
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2/../../../libgthread-2.0.so:
undefined reference to `pthread_create'
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2/../../../libgthread-2.0.so:
undefined reference to `pthread_getspecific'
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2/../../../libgthread-2.0.so:
undefined reference to `pthread_key_create'
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2/../../../libgthread-2.0.so:
undefined reference to `pthread_attr_setstacksize'
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2/../../../libgthread-2.0.so:
undefined reference to `pthread_mutex_trylock'
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2/../../../libgthread-2.0.so:
undefined reference to `pthread_join'
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2/../../../libgthread-2.0.so:
undefined reference to `pthread_cond_timedwait'
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2/../../../libgthread-2.0.so:
undefined reference to `pthread_setspecific'
collect2: ld returned 1 exit status
configure:9831: $? = 1
configure: program exited with status 1
configure: failed program was:
#line 9818 "configure"
#include "confdefs.h"
 #include <stdio.h>
             main ()
             {
               return 0;
             }
configure:9845: error: Linking is badly borked on your system. Please
ensure your library path is correct 	                Check config.log
for details - check near the end of the log above 'failed program was'
----

But you are partially right. I wrote one-line test program with only
g_thread_init() and linked it with 'gcc -o test -lgthread-2.0 test.c'.
Linking failed with few 'libgthread-2.0: undefined refernces to
pthread_...'. When I added -pthread on compiling line compilation
ended fine.
So all other modules with gthread dependancy have to include -pthread
(more strictly 'pkg-config --libs (or --cflags) gthread-2.0' output)
flag or glib HEAD for all that should rollback to glib-2-0 scheme with
-lpthread flag.
Comment 5 Dmitry G. Mastrukov 2002-11-04 10:41:27 UTC
It's a pkgconfig-0.12.0 fault. Digging in config output of ORBit and
linc I found pkgconfig looses -pthread flag. I upgraded to 0.14.0 and
-pthread appears in *_CFLAGS AND *_LIBS.
Seems pkgconfig-0.14.0 should be requrement for building systems based
on glib 2.1 (2.2).