GNOME Bugzilla – Bug 97553
-pthread flag and no libpthread
Last modified: 2004-12-22 21:47:04 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.
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.
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.
Let's back up: - What package failed to compile with GLib HEAD? - What was the error message you got with that package?
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.
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).