# 'MT\_StaticRelease' doesn't match value 'MD\_DynamicRelease'

**URL:** https://discourse.cmake.org/t/mt-staticrelease-doesnt-match-value-md-dynamicrelease/5428
**Category:** Usage
**Tags:** os:windows
**Created:** [April 11, 2022, 7:35am UTC](https://discourse.cmake.org/t/mt-staticrelease-doesnt-match-value-md-dynamicrelease/5428 "2022-04-11T07:35:10Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![alice](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alice/32/1615_2.png) [@alice](https://discourse.cmake.org/u/alice)
#### Post date: [April 11, 2022, 7:35am UTC](https://discourse.cmake.org/t/mt-staticrelease-doesnt-match-value-md-dynamicrelease/5428/1 "2022-04-11T07:35:10Z")

</div>

I see the document RuntimeLibrary part and then I don’t know what can I do.  
[https://docs.microsoft.com/en-us/previous-versions/jj889284(v=vs.140)?redirectedfrom=MSDN](https://docs.microsoft.com/en-us/previous-versions/jj889284(v=vs.140)?redirectedfrom=MSDN)

```auto
libcpmt.lib(StlCompareStringA.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Groupsock.cpp.obj libcpmt.lib(StlLCMapStringW.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Groupsock.cpp.obj

```

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [April 12, 2022, 12:00pm UTC](https://discourse.cmake.org/t/mt-staticrelease-doesnt-match-value-md-dynamicrelease/5428/2 "2022-04-12T12:00:24Z")

</div>

Again, you’re mixing and matching Release and Debug runtimes. I _really_ recommend you get _everything_ using the same runtime.

---

<div class="post-metadata">

### Author: ![Fab](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/f/51bf81/32.png) [@Fab](https://discourse.cmake.org/u/Fab)
#### Post date: [October 5, 2022, 11:26pm UTC](https://discourse.cmake.org/t/mt-staticrelease-doesnt-match-value-md-dynamicrelease/5428/3 "2022-10-05T23:26:39Z")

</div>

No [s]he probably did not @ben.boeckel ,

FWIW, if [s]he did then the message would have been instead as an example (as I tested it to confirm):  
Error|LNK2038|mismatch detected for ‘RuntimeLibrary’: value ‘MT\_StaticRelease’ doesn’t match value ‘ **MTd\_StaticDebug** ’ in …/…

What happened most probaly to @alice (as it happened to me recently while learning more about this issue) is that there is a discrepancy between vtk release build and the app cmake build.

More precisely and typically:  
1- the vtk lib builds fully static and one can check it’s the case using dumpbin /all anyvtklib.obj and check that the linker links with the /LIBCMT option (search for External Linker in the dump)  
2- the app does NOT build properly in static mode because cmakelist.txt flags (or the vcxproj itself if not using cmake) are not correctly configured yet even if no build mixing can happen (because we only use release builds for example).

@alice Assuming you are using cmake for your app that links with VTK, if you just added these in your cmake file it should now work:  
add\_compile\_options(“/MT$\<$CONFIG:Debug:d\>”)

Then for each app or lib, add:  
set\_property(TARGET MyAppNameUsingVTK PROPERTY  
MSVC\_RUNTIME\_LIBRARY “MultiThreaded$\<$CONFIG:Debug:Debug\>”)

If you use directly your own vcxproj solution file, then just go to compiler/code generation and change /MD to /MT (not discussing debug cases here to keep it simple).

---

<div class="post-metadata">

### Author: ![Fab](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/f/51bf81/32.png) [@Fab](https://discourse.cmake.org/u/Fab)
#### Post date: [October 6, 2022, 1:19am UTC](https://discourse.cmake.org/t/mt-staticrelease-doesnt-match-value-md-dynamicrelease/5428/4 "2022-10-06T01:19:33Z")

</div>

Also note that for more recent cmake versions, the best resolution i found if you are using cmake is:

1. Use the CMP0091 policy setting to be able to use the MSVC option in point 2 like this 🙂

```auto
if(POLICY CMP0091)
  cmake_policy(SET CMP0091 NEW) 
endif()

```

1. Then only add the new property definition:

```auto
    set_property(TARGET MyVtkAppOrLibName PROPERTY
        MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

```

for each project it links to,

Note that once the CMP if section is inserted in step 1, we don’t need to set manually the /MP flag , the old cmake way (as it can cause other problems).

---

<div class="post-metadata">

### Author: ![enetheru](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/e/848f3c/32.png) [@enetheru](https://discourse.cmake.org/u/enetheru)
#### Post date: [November 29, 2024, 11:05pm UTC](https://discourse.cmake.org/t/mt-staticrelease-doesnt-match-value-md-dynamicrelease/5428/5 "2024-11-29T23:05:18Z")

</div>

I ran into this recently, and mistakenly thought that the INTERFACE\_ prefix was a universal concept and tried to do something like this:

```auto
set_property(TARGET MyVtkAppOrLibName PROPERTY
        INTERFACE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

```

But unfortunately there is no such property, and no warning for not-predefined properties, so I had to discover my mistake through trial and error.

As far as I can tell there is no way to set this property to be transient, so I am having to fall back to using the global `set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")`

Or once again use `set_compile_options` to propogate the flags to consumers.
