无法构建谷歌模拟

Couldn't build google mock

本文关键字:模拟 谷歌 构建      更新时间:2023-10-16

我尝试使用MinGW在Windows7上构建google mock。但我做不到。

我通过点击"下载Zip"按钮从下面的网站下载了谷歌测试和谷歌模拟。[https://github.com/google/googletest][1]

我解压缩了文件并在命令行上执行命令。

> g++ -c -Iinclude -I. src/gmock-all.cc

但是错误发生了。

> include/gmock/internal/gmock-port.h:53:45: fatal error: gtest/internal/gtest-linked_ptr.h: No such file or directory

我该如何解决?

您应该首先构建googletest,然后构建googlemock。它是捆绑的其中googlemock位于名为"gtest"的子目录中。这就是你需要做的:

g++ -isystem <path_to_gtest>/include -I<path_to_gtest> 
  -isystem <path_to_gmock>/include -I<path_to_gmock> 
  -pthread -c <path_to_gtest>/src/gtest-all.cc
g++ -isystem <path_to_gtest>/include -I<path_to_gtest> 
  -isystem <path_to_gmock>/include -I<path_to_gmock> 
  -pthread -c <path_to_gmock>/src/gmock-all.cc

这肯定会在Linux上工作,但我不能100%确定MinGW在如果没有帮助,我建议使用Visual Studio社区版。您已经在<path_to_gmock>/msvc/2010中设置了VS解决方案。它是VS2010的解决方案,但使用较新版本打开它会提示您升级工具集。简单地接受并构建"gmock"项目solution.o_gmock>/src/gmock-all.cc