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,執行文件,顯示測試結果。
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,執行文件,顯示測試結果。