# ldd /usr/lib64/libgtest.so linux-vdso.so.1 => (0x000002c576dc1000) libstdc++.so.6 => /usr/lib/gcc/x86_64-pc-linux-gnu/4.4.5/libstdc++.so.6 (0x000002c576840000) libc.so.6 => /lib64/libc.so.6 (0x000002c5764d8000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x000002c5762c1000) libm.so.6 => /lib64/libm.so.6 (0x000002c576040000) /lib64/ld-linux-x86-64.so.2 (0x000002c576dc2000) panoramix / # nm -D /usr/lib64/libgtest.so | grep pthread w pthread_cancel U pthread_getspecific U pthread_key_create U pthread_key_delete U pthread_mutex_destroy U pthread_mutex_init U pthread_mutex_lock U pthread_mutex_unlock U pthread_self U pthread_setspecific Reproducible: Always
checking for the pthreads library -lpthreads... no checking whether pthreads work without any flags... no checking whether pthreads work with -Kthread... no checking whether pthreads work with -kthread... no checking for the pthreads library -llthread... no checking whether pthreads work with -pthread... yes checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE checking if more special flags are required for pthreads... no checking whether to check for GCC pthread/shared inconsistencies... yes checking whether -pthread is sufficient with -shared... yes The configure checks are correct. You don't need to link to anything except libc. $ nm -D /lib/libc.so.6 |grep pthread 00000000000df370 T __libc_pthread_init 00000000000de910 T pthread_attr_destroy 00000000000de970 T pthread_attr_getdetachstate 00000000000de9d0 T pthread_attr_getinheritsched 00000000000dea30 T pthread_attr_getschedparam 00000000000dea90 T pthread_attr_getschedpolicy 00000000000deaf0 T pthread_attr_getscope 00000000000de940 T pthread_attr_init 00000000000de9a0 T pthread_attr_setdetachstate 00000000000dea00 T pthread_attr_setinheritsched 00000000000dea60 T pthread_attr_setschedparam 00000000000deac0 T pthread_attr_setschedpolicy 00000000000deb20 T pthread_attr_setscope 0000000000109470 T pthread_cond_broadcast 00000000000debb0 T pthread_cond_broadcast 00000000000debe0 T pthread_cond_destroy 00000000001094a0 T pthread_cond_destroy 00000000000dec10 T pthread_cond_init 00000000001094d0 T pthread_cond_init 00000000000dec40 T pthread_cond_signal 0000000000109500 T pthread_cond_signal 00000000000deca0 T pthread_cond_timedwait 0000000000109560 T pthread_cond_timedwait 00000000000dec70 T pthread_cond_wait 0000000000109530 T pthread_cond_wait 00000000000deb50 T pthread_condattr_destroy 00000000000deb80 T pthread_condattr_init 00000000000de8e0 T pthread_equal 00000000000dee80 T pthread_exit 00000000000decd0 T pthread_getschedparam 00000000000ded30 T pthread_mutex_destroy 00000000000ded60 T pthread_mutex_init 00000000000ded90 T pthread_mutex_lock 00000000000dedc0 T pthread_mutex_unlock 00000000000dedf0 T pthread_self 00000000000dee20 W pthread_setcancelstate 00000000000dee50 T pthread_setcanceltype 00000000000ded00 T pthread_setschedparam
Look more carefully: gtest uses pthread_key_*.
(In reply to comment #1) > The configure checks are correct. You don't need to link to anything except > libc. No. glibc seems to be providing *some* of pthread symbols, but not all off them, namely pthread_key_* and pthread_*specific: # nm -D /lib/libc.so.6 | grep -E 'pthread_(.*specific|key)' # nm -D /lib/libpthread.so.0 | grep -E 'pthread_(.*specific|key)' 000000000000c5e0 T __pthread_getspecific 000000000000c540 T __pthread_key_create 000000000000c660 T __pthread_setspecific 000000000000c5e0 T pthread_getspecific 000000000000c540 T pthread_key_create 000000000000c5a0 T pthread_key_delete 000000000000c660 T pthread_setspecific Currently the library isn't expressing that dependency.
I have the same problem here. Solved the problem with a quick fix to the dev-util/gtest ebuild. Instead of using autoconf and friends I used the experimental CMake script provided. I had to alter it a little (added installation routine and an option to build without pthread library) and change the ebuild accordingly. My ebuild does not support 'static-libs' anymore (as far as I see: none of the packages in the Gentoo tree need it) and there is no symlinking or version numbering of the library like '/usr/lib/libgtest.so -> libgtest.so.0.0.0', instead just plain and simple '/usr/lib/libgtest.so'. I was too lazy to do the replacement of the placeholders in 'gtest-config.in' manually, so for that bit I am still using the configure-script -- not aesthetically pleasing, but it works (at least for sys-apps/paludis-0.68.0). Anyways, I will attach my quick fix. Related bug at Google Code: http://code.google.com/p/googletest/issues/detail?id=336
Created attachment 288055 [details, diff] files/gtest-1.5.0-pthread-as-needed.patch switch from static to shared lib generation; provided install routines (installs gtest-config, which is generated by the configure script -- not pretty)
Created attachment 288057 [details, diff] patch to gtest 1.5.0 ebuild
Created attachment 326650 [details] configure-fix-pthread-linking.patch Still a problem in 1.6.0. I've attached a fix that doesn't require using cmake as the previous fix still wasn't applied.
Fixed in dev-cpp/gtest-1.6.0-r1
(In reply to comment #8) did you send these changes to the respective upstream ? the patch name is also wrong in the tree. you should follow the ${P} standard.