包含gmock / gmock.h会导致编译错误

时间:2019-05-23 18:15:59

标签: c++ googletest gmock vcpkg

简单的代码

#include "gmock/gmock.h"

给出了许多编译错误,仅举几个例子

Severity    Code    Description Project File    Line    Suppression State
Error (active)  E0020   identifier "MatcherDescriberInterface" is undefined google_test C:\Users\blobber\Source\Repos\vcpkg\installed\x64-windows\include\gmock\gmock-matchers.h    2874    
Error (active)  E0135   namespace "testing::internal" has no member "IgnoredValue"  google_test C:\Users\blobber\Source\Repos\vcpkg\installed\x64-windows\include\gmock\gmock-actions.h 1045    
Error (active)  E0020   identifier "MatchResultListener" is undefined   google_test C:\Users\blobber\Source\Repos\vcpkg\installed\x64-windows\include\gmock\gmock-matchers.h    330 
Error (active)  E0020   identifier "MatchResultListener" is undefined   google_test C:\Users\blobber\Source\Repos\vcpkg\installed\x64-windows\include\gmock\gmock-matchers.h    516 
Error (active)  E0020   identifier "MatchResultListener" is undefined   google_test C:\Users\blobber\Source\Repos\vcpkg\installed\x64-windows\include\gmock\gmock-matchers.h    532 

我先安装vcpkg,然后使用vcpkg install gtest:x64-windows安装了Google Test(该产品包括了Google Mock),从而安装了gmock。 Google Test可以正常工作。

Compile error when I #include "gmock/gmock.h"提到在我的主程序中包含InitGoogleMock(&__ argc,__argv),但在我的Visual Studio GoogleTest项目中没有主程序。

0 个答案:

没有答案