How to build Google test in Visual Studio 2013?

172 views Asked by At

Updated question:

I am trying to build Google test in VS 2013 Pro. Because it supports C++11, so I downloaded Google test version 1.8.1 in https://github.com/google/googletest/releases/tag/release-1.8.1.

After that I used CMake GUI 3.26.3 (latest version CMake) to create .sln file and load into Visual Studio.

enter image description here

Then I tried to build the solution. But there were some errors relating to gmock-matchers.h

Below are the errors in the output pane:

1>------ Build started: Project: ZERO_CHECK, Configuration: Debug Win32 ------
1>  Checking Build System
2>------ Build started: Project: gtest, Configuration: Debug Win32 ------
3>------ Build started: Project: gmock, Configuration: Debug Win32 ------
4>------ Build started: Project: gmock_main, Configuration: Debug Win32 ------
5>------ Skipped Build: Project: RUN_TESTS, Configuration: Debug Win32 ------
5>Project not selected to build for this solution configuration 
2>  Building Custom Rule C:/Users/LocalAdmin/Desktop/googletest-release-1.8.1/googletest/CMakeLists.txt
2>  gtest-all.cc
3>  Building Custom Rule C:/Users/LocalAdmin/Desktop/googletest-release-1.8.1/googlemock/CMakeLists.txt
4>  Building Custom Rule C:/Users/LocalAdmin/Desktop/googletest-release-1.8.1/googlemock/CMakeLists.txt
3>  gtest-all.cc
4>  gtest-all.cc
3>  gmock-all.cc
4>  gmock-all.cc
3>C:\Users\LocalAdmin\Desktop\googletest-release-1.8.1\googlemock\include\gmock/gmock-matchers.h(62): error C2220: warning treated as error - no 'object' file generated
3>C:\Users\LocalAdmin\Desktop\googletest-release-1.8.1\googlemock\include\gmock/gmock-matchers.h(62): warning C4616: #pragma warning : warning number '5046' not a valid compiler warning
4>C:\Users\LocalAdmin\Desktop\googletest-release-1.8.1\googlemock\include\gmock/gmock-matchers.h(62): error C2220: warning treated as error - no 'object' file generated
4>C:\Users\LocalAdmin\Desktop\googletest-release-1.8.1\googlemock\include\gmock/gmock-matchers.h(62): warning C4616: #pragma warning : warning number '5046' not a valid compiler warning
2>  gtest.vcxproj -> C:\Users\LocalAdmin\Desktop\googletest-release-1.8.1\build\googlemock\gtest\Debug\gtestd.lib
3>  Generating Code...
4>  gmock_main.cc
6>------ Build started: Project: gtest_main, Configuration: Debug Win32 ------
6>  Building Custom Rule C:/Users/LocalAdmin/Desktop/googletest-release-1.8.1/googletest/CMakeLists.txt
4>C:\Users\LocalAdmin\Desktop\googletest-release-1.8.1\googlemock\include\gmock/gmock-matchers.h(62): error C2220: warning treated as error - no 'object' file generated
4>C:\Users\LocalAdmin\Desktop\googletest-release-1.8.1\googlemock\include\gmock/gmock-matchers.h(62): warning C4616: #pragma warning : warning number '5046' not a valid compiler warning
6>  gtest_main.cc
4>  Generating Code...
6>  gtest_main.vcxproj -> C:\Users\LocalAdmin\Desktop\googletest-release-1.8.1\build\googlemock\gtest\Debug\gtest_maind.lib
7>------ Build started: Project: ALL_BUILD, Configuration: Debug Win32 ------
7>  Building Custom Rule C:/Users/LocalAdmin/Desktop/googletest-release-1.8.1/CMakeLists.txt
8>------ Skipped Build: Project: INSTALL, Configuration: Debug Win32 ------
8>Project not selected to build for this solution configuration 
========== Build: 4 succeeded, 2 failed, 0 up-to-date, 2 skipped ==========

I found 2 links for that errors but it doesn't help me much: https://github.com/google/googletest/issues/1848

Compile error when I #include "gmock/gmock.h"

Could you help me to solve this? I am totally a newbie with Google test.

1

There are 1 answers

2
273K On

Visual Studio 2013 is unable to compile release-1.12.0 with the compiler requirements:

Compilers

  • MSVC 2015+

You might want to try release-1.8.1, that is the last one that works with pre-C++11 compilers such as MSVC 2013.