How to setup googletest on Linux in the year 2012?

前端 未结 3 1012
孤城傲影
孤城傲影 2021-02-01 19:37

I am using Linux machine. I have download the googletest package from here

However, there is no installation guide or other blogs related on how to set it up properly Th

3条回答
  •  深忆病人
    2021-02-01 20:35

    An addendum to James C's answer:

    Note that building the library using gtest-1.6.0/src/gtest-all.cc will require you to provide with a main method yourself. If you want to avoid that altogether and use the default implementation of the main method provided by Googletest, build your library including gtest_main.cc.

    That is:

    g++ -Igtest-1.6.0/include -Igtest-1.6.0 -c gtest-1.6.0/src/gtest-all.cc gtest-1.6.0/src/gtest_main.cc
                                                                                           ^^^^^^^^^^^^^^
    ar -rv libgtest_main.a gtest_main.o gtest-all.o
                           ^^^^^^^^^^^^
    

    Also, keep in mind that implementing your own main method is not the recommended way of defining the SetUp and TearDown behaviours; you should be using fixtures instead. Check the Googletest documentation on the topic.

提交回复
热议问题