gtest build fails with pthread errors
As described in #239, the invocation of make check fails with the following errors:
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libgtest.a(gtest-all.cc.o): undefined reference to symbol pthread_getspecific@@GLIBC_2.2.5'
/usr/bin/ld: /lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
This appears to be an issue with the pthread flags not being passed in to the linking stage of the build of google test. The issue was observed on a debian system using GCC. If possible, please provide the following information to help with reproduction:
- version of debian (e.g.
/etc/debian_version) - versions of cmake and gcc
A few first ideas:
It looks like include(FindThreads) was inadvertently removed from the cmake build at some point, which later variables including CMAKE_THREAD_LIBS_INIT depend on. Please add this to the top of tools/cmake/google_libs.cmake and see if the issue is resolved in a fresh configure/build.
If that doesn't work, please try updating the google_libs_cxx_flags variable in tools/cmake/google_libs.cmake to include -pthread at the end:
if(CYGWIN)
set(google_libs_cxx_flags "-std=gnu++11 -pthread")
else()
set(google_libs_cxx_flags "-std=c++11 -pthread")
endif()
This will be closed in a month if no further context is provided for the issue, under the assumption that the proposed fixes resolved the problem.