1、从官网下载gtest 

2、使用unzip解压文件(zip格式)
3、进入make文件夹,make。
4、如果编译不通过,提示”undefined reference to 'pthread setspecific'”,修改make文件(Makefile)将-lpthread 放到最后。如下:
g++ -I../include -g -Wall -Wextra sample1.o sample1-unittest.o gtest_main.a -o sample1_unittest -lpthread.
5、编译完成,生成执行文件sample1_unittest,执行文件,显示测试结果。