1

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.

gnase
  • 580
  • 2
  • 10
  • 25
  • 1
    Full support for C++11 [appears](https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance?view=msvc-170) only in MSVC 2015. Concerning `contsexpr` see e.g. [that question](https://stackoverflow.com/questions/18513618/why-does-msvc11-rejects-constexpr-qualification-of-a-function). – Tsyvarev Apr 25 '23 at 22:15
  • 1
    Don't post images of errors. Copy a couple of complete top errors from Output pane and paste them as a formatted text in the question. – 273K Apr 26 '23 at 03:40
  • 1
    @273K: I have updated the errors in my question. Please help me if you have any idea. Thanks! – gnase Apr 26 '23 at 06:03
  • The manual to VS 2013 is missing for me, perhaps that warning 5046 is for the newer VS 2015, or 2013 with the latest update. I would comment out that `#pragma warning(disable : 5046)`. – 273K Apr 28 '23 at 06:46

1 Answers1

1

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.

273K
  • 29,503
  • 10
  • 41
  • 64
  • thanks for your help and sorry to bother you again. I have updated my question above. It still has error with `gmock-matcher.h`. I don't understand this error, should I use an older version of CMake? – gnase Apr 26 '23 at 10:14
  • Try to comment out `#pragma warning(disable : 5046)` – 273K Apr 28 '23 at 06:46