cmake – Different behaviour of Visual Studio when two users link the same code


My colleague can build our project, while I get the following linker errors:

26>gtest.lib(gtest-all.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in ReadInExpectedValues.obj
26>gtest.lib(gtest-all.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in ReadInExpectedValues.obj

What is this difference due to?

Consider that we are using the same:

  • Source code (checked-out from git, last commit).
  • Windows 11 version.
  • Visual Studio 17.14.10 / MSVC 19.44.35213.0.
  • CMake 3.31.6-msvc6 (from Developer PowerShell).
  • Google Test is part of the project, so same version (from 2005).

Also:

  • The ‘_ITERATOR_DEBUG_LEVEL’ string is not present in our project and dependencies (even if ReadInExpectedValues.obj is one of our object files).
  • The ‘RuntimeLibrary’ string is present in all the .vcxproj files always as:
    <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>, so all code should be built as MultiThreadedDebugDLL, with no mismatches.

Leave a Reply

Your email address will not be published. Required fields are marked *