[gmx-developers] pthreads missing when attempting to link with libgtest.so

Teemu Murtola teemu.murtola at gmail.com
Sat Sep 3 10:24:49 CEST 2011


On Fri, Sep 2, 2011 at 17:38, Gernot Ziegler <gziegler at nvidia.com> wrote:
> Being a newbie to Gromacs compilation (but not Linux source compilation in
> general), I just stumbled over the following when trying to compile a
> Gromacs freshly pulled via git:

> localhost gromacs # make
> [  0%] Generating version information
> [  0%] Built target gmx_version
> [ 72%] Built target libgromacs
> [ 72%] Built target template
> [ 73%] Built target testutils
> Linking CXX executable testutils-test
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.4.6/../../../../lib64/libgtest.so:
> undefined reference to `pthread_key_create'
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.4.6/../../../../lib64/libgtest.so:
> undefined reference to `pthread_getspecific'
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.4.6/../../../../lib64/libgtest.so:
> undefined reference to `pthread_key_delete'
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.4.6/../../../../lib64/libgtest.so:
> undefined reference to `pthread_setspecific'
> collect2: ld returned 1 exit status
> make[2]: *** [src/testutils/tests/testutils-test] Error 1
> make[1]: *** [src/testutils/tests/CMakeFiles/testutils-test.dir/all] Error 2
> make: *** [all] Error 2
>
> The system is Gentoo Linux AMD64, using gcc 4.4.6, CMake cache as follows:
> All hints welcomed! And let me know if you need more information :-)

It appears that the FindGTest module (that has been copied verbatim
from some CMake 2.8.x distribution) doesn't work correctly with a
dynamically linked libgtest in that it doesn't report the dependency
on pthreads. I don't know what would be the best solution, but there
are some hacks that you can try locally to make things compile
(haven't tried these myself, but with some tuning, they should work):
add pthreads to either GTEST_LIBRARIES in the main CMakeLists.txt or
to TESTUTILS_LIBS in src/testutils/CMakeLists.txt. Or link to gtest
statically, which works at least for me on OS X. Alternatively, you
can turn off BUILD_TESTING if you are not interested in the unit tests
(that currently cover only very specific parts of the code), or use
the release-4-5-patches branch if you are not interested in the
currently very unstable work-in-progress in the master branch.

BR,
Teemu



More information about the gromacs.org_gmx-developers mailing list