Google Test 配置使用

https://github.com/google/googletest/blob/master/googletest/README.md

1、下载Google test框架

在本机git clone https://github.com/google/googletest.git

然后进入googletest/googletest/目录(两层),然后执行下面两条命令编译google test

# g++ -isystem ./include -I./ -pthread -c ./src/gtest-all.cc
   
# ar -rv libgtest.a gtest-all.o

2、 使用google test

参考:https://blog.csdn.net/qq_35976351/article/details/79634857 (test.cpp)

在本机任意位置创建test.cpp,编译的时候使用如下命令编译程序

g++ -isystem (google test's path)/include -pthread test.cpp \
      (gtest's path)/libgtest.a -o binary_program

例如

g++ -isystem ~/googletest/googletest/include -pthread test.cpp \         
     ~/googletest/googletest/libgtest.a -o test_gtest

最终直接执行./test_gtest即可

3、这里也可以创建一个CMakeLists.txt,使用cmake来简化编译过程

猜你喜欢

转载自blog.csdn.net/csd_meb/article/details/81167316
今日推荐