How to set up googleTest as a shared library on Linux

后端 未结 12 2624
北荒
北荒 2020-11-28 01:04

Debian does not provide any precompiled packages for gTest anymore. They suggest you integrate the framework into your project\'s makefile. But I want to keep my makefile cl

12条回答
  •  隐瞒了意图╮
    2020-11-28 01:59

    Let me answer this specifically for ubuntu users. First start by installing the gtest development package.

    sudo apt-get install libgtest-dev
    

    Note that this package only install source files. You have to compile the code yourself to create the necessary library files. These source files should be located at /usr/src/gtest. Browse to this folder and use cmake to compile the library:

    sudo apt-get install cmake # install cmake
    cd /usr/src/gtest
    sudo mkdir build
    cd build
    sudo cmake ..
    sudo make
    sudo make install
    

    Now to compile your programs that uses gtest, you have to link it with:

    -lgtest -lgtest_main -lpthread
    

    This worked perfectly for me on Ubuntu 14.04LTS.

提交回复
热议问题