title: RuntimeLibrary mismatch error when importing Protobuf (Win64, CMake)
body: <p>I have a project whose architecture is as follows:</p>
  <pre><code>├── CMakeLists.txt
  ├── projects
  │   ├── CMakeLists.txt
  │   ├── io
  │   │   ├── CMakeLists.txt
  │   │   ├── data.proto
  │   │   └── generated
  │   │       ├── data.pb.cc
  │   │       └── data.pb.h
  │   ├── service
  │   │   ├── CMakeLists.txt
  │   │   └── main.cpp
  │   ├── dll_project_1
  │   └── dll_project_2
  └── third_party
      └── protobuf
          ├── bin
          ├── cmake
          ├── include
          └── lib
  </code></pre>
  <p>The <strong>projects</strong> directory contains all my projects (obviously):</p>
  <ul>
  <li><strong>service</strong> is the executable project</li>
  <li><strong>io</strong> a static library, in which I want to only edit the &quot;.proto&quot; files</li>
  <li>The other projects are some <strong>shared libraries</strong> basically</li>
  </ul>
  <p>The <strong>third_party/protobuf</strong> contains all the protobuf installed files listed <a href="https://github.com/protocolbuffers/protobuf/tree/master/cmake#installing" rel="nofollow noreferrer">here</a>. Note that, to install protobuf, I followed all the instructions <a href="https://github.com/protocolbuffers/protobuf/tree/master/cmake" rel="nofollow noreferrer">here</a> (using Visual Studio for Compilation and Installation, in both Debug x64 and Release x64).</p>
  <p>The <code>CMakeLists.txt</code> are as follows:</p>
  <p><strong>./CMakeLists.txt</strong></p>
  <pre><code>set(THIRD_PARTY ${CMAKE_CURRENT_SOURCE_DIR}/third_party)
  set(PROTOBUF ${THIRD_PARTY}/protobuf)
  
  set(Protobuf_USE_STATIC_LIBS ON)
  
  include(${PROTOBUF}/cmake/protobuf-config.cmake)
  include(${PROTOBUF}/cmake/protobuf-module.cmake)
  include(${PROTOBUF}/cmake/protobuf-options.cmake)
  include(${PROTOBUF}/cmake/protobuf-targets.cmake)
  
  find_package(Protobuf REQUIRED HINTS ${PROTOBUF})
  include_directories(${Protobuf_INCLUDE_DIRS})
  link_libraries(${Protobuf_LIBRARIES})
  </code></pre>
  <p><strong>./projects/CMakeLists.txt</strong></p>
  <pre><code>add_subdirectory(io)
  add_subdirectory(dll_project_1)
  add_subdirectory(dll_project_2)
  
  add_subdirectory(service)
  </code></pre>
  <p><strong>./projects/io/CMakeLists.txt</strong></p>
  <pre><code>set(PROTO
      data.proto
  )
  
  set(PROTO_GENERATED
      generated/data.pb.cc
      generated/data.pb.h
  )
  
  source_group(Proto FILES ${PROTO})
  source_group(Generated FILES ${PROTO_GENERATED})
  
  add_library(IO STATIC ${PROTO} ${PROTO_GENERATED})
  </code></pre>
  <p><strong>./projects/service/CMakeLists.txt</strong></p>
  <pre><code>add_executable(Service main.cpp)
  
  target_link_libraries(Service
      IO
      Dll1
      Dll2
  )
  </code></pre>
  <p>Now cmake build the solution ok, and what I'm just trying to do is just something like:</p>
  <pre><code>#include &quot;../io/generated/data.pb.h&quot;
  
  int main()
  {
      Data::SomeData d;
      d.set_value(0.0);
  }
  </code></pre>
  <p>But when I try to compile I get a lot of LNK2038 and LNK2005 errors:</p>
  <pre><code>6&gt;main.cpp
  6&gt;libprotobufd.lib(common.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(common.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(common.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(coded_stream.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(coded_stream.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(coded_stream.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(arena.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(arena.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(arena.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(message_lite.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(message_lite.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(message_lite.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(parse_context.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(parse_context.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(parse_context.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(generated_message_util.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(generated_message_util.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(generated_message_util.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(unknown_field_set.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(unknown_field_set.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(unknown_field_set.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(generated_message_reflection.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(generated_message_reflection.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(generated_message_reflection.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(message.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(message.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(message.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(reflection_ops.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(reflection_ops.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(reflection_ops.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(wire_format.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(wire_format.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(wire_format.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(status.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(status.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(status.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(int128.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(int128.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(int128.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(stringpiece.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(stringpiece.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(stringpiece.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(strutil.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(strutil.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(strutil.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(zero_copy_stream.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(zero_copy_stream_impl_lite.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(zero_copy_stream.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(zero_copy_stream.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(zero_copy_stream_impl_lite.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(zero_copy_stream_impl_lite.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(zero_copy_stream_impl.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(zero_copy_stream_impl.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(zero_copy_stream_impl.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(structurally_valid.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(structurally_valid.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(structurally_valid.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(repeated_field.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(repeated_field.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(repeated_field.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(wire_format_lite.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(wire_format_lite.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(wire_format_lite.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(extension_set.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(extension_set.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(extension_set.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(descriptor.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(descriptor.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(descriptor.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(arenastring.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(arenastring.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(arenastring.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(extension_set_heavy.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(extension_set_heavy.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(extension_set_heavy.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(map_field.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(map_field.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(map_field.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(io_win32.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(io_win32.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(io_win32.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(implicit_weak_message.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(implicit_weak_message.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(implicit_weak_message.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(stringprintf.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(stringprintf.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(stringprintf.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(text_format.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(text_format.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(text_format.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(descriptor.pb.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(descriptor.pb.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(descriptor.pb.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(tokenizer.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(tokenizer.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(tokenizer.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(descriptor_database.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(descriptor_database.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(descriptor_database.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(dynamic_message.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(dynamic_message.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(dynamic_message.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(substitute.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(substitute.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(substitute.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(strtod.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(strtod.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(strtod.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(any_lite.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(any_lite.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(any_lite.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(map.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(map.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(map.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libprotobufd.lib(any.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libprotobufd.lib(any.obj) : warning LNK4099: PDB 'libprotobuf.pdb' was not found with 'libprotobufd.lib(any.obj)' or at 'C:\dev\MyProject\build\Debug\libprotobuf.pdb'; linking object as if no debug info
  6&gt;libcpmtd.lib(locale0.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libcpmtd.lib(locale0.obj) : error LNK2005: &quot;void __cdecl std::_Facet_Register(class std::_Facet_base *)&quot; (?_Facet_Register@std@@YAXPEAV_Facet_base@1@@Z) already defined in msvcprtd.lib(locale0_implib.obj)
  6&gt;libcpmtd.lib(locale0.obj) : error LNK2005: &quot;private: static class std::locale::_Locimp * __cdecl std::locale::_Getgloballocale(void)&quot; (?_Getgloballocale@locale@std@@CAPEAV_Locimp@12@XZ) already defined in msvcprtd.lib(MSVCP140D.dll)
  6&gt;libcpmtd.lib(locale0.obj) : error LNK2005: &quot;private: static class std::locale::_Locimp * __cdecl std::locale::_Init(bool)&quot; (?_Init@locale@std@@CAPEAV_Locimp@12@_N@Z) already defined in msvcprtd.lib(MSVCP140D.dll)
  6&gt;libcpmtd.lib(locale0.obj) : error LNK2005: &quot;public: static void __cdecl std::_Locinfo::_Locinfo_ctor(class std::_Locinfo *,char const *)&quot; (?_Locinfo_ctor@_Locinfo@std@@SAXPEAV12@PEBD@Z) already defined in msvcprtd.lib(MSVCP140D.dll)
  6&gt;libcpmtd.lib(locale0.obj) : error LNK2005: &quot;public: static void __cdecl std::_Locinfo::_Locinfo_dtor(class std::_Locinfo *)&quot; (?_Locinfo_dtor@_Locinfo@std@@SAXPEAV12@@Z) already defined in msvcprtd.lib(MSVCP140D.dll)
  6&gt;libcpmtd.lib(locale.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libcpmtd.lib(iosptrs.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libcpmtd.lib(wlocale.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libcpmtd.lib(xlocale.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libcpmtd.lib(xstol.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libcpmtd.lib(xstoul.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libcpmtd.lib(xstoll.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libcpmtd.lib(xstoull.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libcpmtd.lib(xlock.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libcpmtd.lib(xlock.obj) : error LNK2005: &quot;public: __cdecl std::_Lockit::_Lockit(int)&quot; (??0_Lockit@std@@QEAA@H@Z) already defined in msvcprtd.lib(MSVCP140D.dll)
  6&gt;libcpmtd.lib(xlock.obj) : error LNK2005: &quot;public: __cdecl std::_Lockit::~_Lockit(void)&quot; (??1_Lockit@std@@QEAA@XZ) already defined in msvcprtd.lib(MSVCP140D.dll)
  6&gt;libcpmtd.lib(xstrcoll.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libcpmtd.lib(xdateord.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libcpmtd.lib(xwcscoll.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libcpmtd.lib(xwcsxfrm.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libcpmtd.lib(xstrxfrm.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libcpmtd.lib(xmtx.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libcpmtd.lib(StlCompareStringA.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libcpmtd.lib(winapinls.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libcpmtd.lib(StlCompareStringW.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libcpmtd.lib(StlLCMapStringW.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libcpmtd.lib(StlLCMapStringA.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;libcpmtd.lib(winapisupp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
  6&gt;MSVCRTD.lib(initializers.obj) : warning LNK4098: defaultlib 'libcmtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
  6&gt;C:\dev\MyProject\build\Debug\Service.exe : fatal error LNK1169: one or more multiply defined symbols found
  6&gt;Done building project &quot;Service.vcxproj&quot; -- FAILED.
  </code></pre>
  <p>I found <a href="https://stackoverflow.com/questions/14714877/mismatch-detected-for-runtimelibrary">this SO question</a> in the first place but I can't see how to do what's answered it with cmake..</p>