undefined reference to `pthread_key_create' (linker error)

前端 未结 5 713
庸人自扰
庸人自扰 2020-11-29 11:51

I have downloaded gtest 1.7.0 sources from here:

https://code.google.com/p/googletest/downloads/list

and build the gtest .a files (lib files) on ubuntu 13.10

5条回答
  •  孤街浪徒
    2020-11-29 12:58

    Nope, the problem is with Gtest's build.

    If you build it using the standard configure approach, it isn't supplying the -lpthread correctly to create libgtest.so. Hence, when you try building a final shared library that actually uses the pthread capability it fails.

    Instead, use the Cmake approach:

    cd gtest-1.7.0
    mkdir build
    cd build
    cmake -DBUILD_SHARED_LIBS=ON ..
    make 
    

    And then manually install these into /usr/lib/

    This version correctly links in libpthread into libgtest.

提交回复
热议问题