Results 1 to 3 of 3

Thread: Yet another pthread linker problemer

  1. #1
    Join Date
    Mar 2007
    Beans
    Hidden!

    Yet another pthread linker problemer

    Hello experts

    I want to try google test framework for c++ on ubuntu. I'm trying to build a very simple test (stripped down from one of the samples supplied by google from gtest).

    My build line and output looks like:
    g++ -o "HelloUnitTest" ./src/HelloUnitTest.o ./Test/TestMain.o -pthread -lgtest -lgtest_main
    /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libgtest.so: undefined reference to `pthread_key_create'
    /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libgtest.so: undefined reference to `pthread_getspecific'
    /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libgtest.so: undefined reference to `pthread_key_delete'
    /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libgtest.so: undefined reference to `pthread_setspecific'
    collect2: error: ld returned 1 exit status

    I have read all posts I could find about this, and tried lpthread vs pthread, linking libraries before and after the object files, linking libpthread as a static library, and many others.

    Any idea what I can be doing wrong?

    ps. running on ubuntu 13.10, 64 bits

  2. #2
    Join Date
    Aug 2010
    Location
    Lancs, United Kingdom
    Beans
    1,080
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: Yet another pthread linker problemer

    I can't seem to get the .so to work either. If you force use of the static library
    Code:
    g++  -o "HelloUnitTest" ./src/HelloUnitTest.o  ./Test/TestMain.o -pthread -l:libgtest.a -l:libgtest_main.a
    then that seems to work.

  3. #3
    Join Date
    Mar 2007
    Beans
    Hidden!

    Re: Yet another pthread linker problemer

    Brilliant Thanks, that solved by problem. Any explanation why this is?

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •