0

I am trying to use the DirectXTex library for my project. I cloned it from GitHub and built it using the Visual Studio 2019 solution for desktop, with the exact same code generation settings as in my own project. It works fine for debug configurations, but when I build on release, an error message similar to this occurs:

_ITERATOR_DEBUG_LEVEL: Value 2 of (some DirectXTex .obj) is conflicting with value 0 of (my own .obj)

which goes along with this message:

Runtime library: MTd_StaticDebug of (some DirectXTex .obj) is conflicting with MT_StaticRelease of (my own .obj)

This is strange, because I set the runtime library of both projects to Multithreaded (/MT) for release and Multithreaded-Debug (/MTd) for debug. I have done some research and found this article that covers this exact problem, but none of those solutions work for me. I tried the following:

  • See if _DEBUG preprocessor is defined in release mode build of DirectXTex for some reason (it is not)
  • Try to set both project settings to Multithreaded-DLL
  • Checked if all code generation settings are really the same (debug and release)
  • Checked if I use the correct library build for debug and release
  • Made a clean new build in case my .obj files are older versions

None of these worked. But it compiles and works fine for release if I set the runtime library of my own project to Multithreaded-Debug for release mode aswell. This is obviously not an ideal solution.

What I also don't understand is that the DirectXTex library seems to build the release configuration of DirectXTex with MT_StaticDebug (at least the error message indicates that), although I explicitly set its runtime library to Multithreaded (/MT) for release. How can I fix this?

  • I think the error message is quite clear: DirectXTex is compiled in debug mode (with `NDEBUG` and `RELEASE` not defined) and links debug runtime. – user7860670 Sep 24 '20 at 15:12
  • @user7860670 But NDEBUG is defined in Release, just _DEBUG is not defined, exactly as it should be. My problem is that I explicitly compile DirectXTex with /MT, but somehow, the DirectXTex .objs seem to be compiled with /MTd. I also link with the Release version of the library in my project. Are there any possible linker options in the library or my project that I can check? –  Sep 24 '20 at 19:56

1 Answers1

0

The DirectXTex_Desktop_2019.vcxproj in the GitHub repo is set to use /MDd for Debug and /MD for Release. Using the DLL-based Visual C++ runtime is recommended for numerous reasons over static CRT linking.

With that said, if you are using static linking, then you should verify that in each Platform/Configuration combination that they are set correctly as it seems like you don't have /MTd set in all of Debug configurations cases. For example, do you have both x86 and x64 platforms in your project?

Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81
  • Turns out that my configuration was correct, but Visual Studio had not updated the .vxproj file correctly when I changed the project settings. Changing the settings in the .vxproj manually fixed the problem. –  Sep 26 '20 at 14:01
  • I've noticed some issues with the Project Settings dialog lately when trying to set multiple config/platform combos at once, so that was probably what happened to you. – Chuck Walbourn Sep 27 '20 at 04:47
  • I am glad you have got your solution and thanks for your sharing, I would appreciate it if you mark them as answer and this will be beneficial to other community. – Barrnet Chou Oct 07 '20 at 01:23