How to set up googleTest as a shared library on Linux

后端 未结 12 2655
北荒
北荒 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:41

    I was similarly underwhelmed by this situation and ended up making my own Ubuntu source packages for this. These source packages allow you to easily produce a binary package. They are based on the latest gtest & gmock source as of this post.

    Google Test DEB Source Package

    Google Mock DEB Source Package

    To build the binary package do this:

    tar -xzvf gtest-1.7.0.tar.gz
    cd gtest-1.7.0
    dpkg-source -x gtest_1.7.0-1.dsc
    cd gtest-1.7.0
    dpkg-buildpackage
    

    It may tell you that you need some pre-requisite packages in which case you just need to apt-get install them. Apart from that, the built .deb binary packages should then be sitting in the parent directory.

    For GMock, the process is the same.

    As a side note, while not specific to my source packages, when linking gtest to your unit test, ensure that gtest is included first (https://bbs.archlinux.org/viewtopic.php?id=156639) This seems like a common gotcha.

提交回复
热议问题