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

Gernot Ziegler gziegler at nvidia.com
Tue Sep 6 15:03:04 CEST 2011


Changing the following line in src/testutils/CMakeLists.txt
from
set(TESTUTILS_LIB testutils)
to
set(TESTUTILS_LIB testutils pthread)
did the trick. :-)

Thank you for the hint! 

> -----Original Message-----
> From: gmx-developers-bounces at gromacs.org [mailto:gmx-developers-
> bounces at gromacs.org] On Behalf Of Teemu Murtola
> Sent: 03 September 2011 10:25
> To: Discussion list for GROMACS development
> Subject: Re: [gmx-developers] pthreads missing when attempting to link
> with libgtest.so
> 
> 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
> --
> gmx-developers mailing list
> gmx-developers at gromacs.org
> http://lists.gromacs.org/mailman/listinfo/gmx-developers
> Please don't post (un)subscribe requests to the list. Use the
> www interface or send it to gmx-developers-request at gromacs.org.
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------



More information about the gromacs.org_gmx-developers mailing list