无法构建 google 模拟

Couldn't build google mock

我尝试使用 MinGW 在 Windows 7 上构建 google 模拟。但是我做不到。

我通过单击 'Download Zip' 按钮从下面的网站下载了 google 测试和 google 模拟。 [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。捆绑销售 在名为 "gtest" 的子目录中使用 googlemock。这是你需要做的:

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 Win7。如果没有帮助,我建议使用 Visual Studio Community Edition。 您已经在 <path_to_gmock>/msvc/2010 中设置了 VS 解决方案。它 是VS2010的解决方案,但是用较新的版本打开会提示 升级工具集。只需接受并在其中构建 "gmock" 项目 solution.o_gmock>/src/gmock-all.cc