CMake cannot find GoogleTest required library in Ubuntu

后端 未结 4 1291
慢半拍i
慢半拍i 2020-12-14 07:52

Similar issue here.

This is my CMakeLists.txt:

cmake_minimum_required(VERSION 2.6)

# Locate GTest
find_package(GTest REQUIRED)
include_directories($         


        
4条回答
  •  隐瞒了意图╮
    2020-12-14 08:16

    Google test was probably not properly installed (libgtest-dev may install only source files that needed to be compiled). I had the same problem and I followed the instructions from http://www.eriksmistad.no/getting-started-with-google-test-on-ubuntu/

    sudo apt-get install libgtest-dev
    sudo apt-get install cmake # install cmake
    cd /usr/src/gtest
    sudo cmake CMakeLists.txt
    sudo make
    
    #copy or symlink libgtest.a and libgtest_main.a to your /usr/lib folder
    sudo cp *.a /usr/lib
    

    This worked for me.

提交回复
热议问题