error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj

前端 未结 20 1028
耶瑟儿~
耶瑟儿~ 2020-11-29 20:36

I have read a lot of solutions to my problem but none helped. I tried clean, rebuild. Reinstalled visual 2010 and change from professional to ultimate. But still I dont know

相关标签:
20条回答
  • 2020-11-29 21:25

    I make a little update on this issue, as I just had the same error today on an application which is linking against a static lib, after I migrated the old Visual 6 project to Visual Studio 2012.

    In my case the error was that I mistakenly compiled the Release version of the static lib with /MDd instead of /MD, whereas the application is /MD in release. Setting the correct /MD in the static lib project solved the issue.

    This is done in Project properties

    • Select Configuration Properties / C C++ / Code Generation in the tree
    • and the option Runtime Library set to the same on all your dependencies projects and application.
    0 讨论(0)
  • 2020-11-29 21:25

    Like all the other answers, I checked my Configuration Properties -> C/C++ -> Preprocessor directives.
    In my case I had the NDEBUG correctly defined in Release, but I also had: _SECURE_SCL=1.

    Removing that one fixed the issue.

    0 讨论(0)
  • 2020-11-29 21:26

    I had a mismatch between projects: one with multi-byte character set, the other with Unicode. Correcting these to agree on Unicode corrected the problem.

    0 讨论(0)
  • 2020-11-29 21:26

    In my case the NDEBUG macro definition in the "Preprocessor Definitions" needed to be changed to _DEBUG. I am building a static library for use in a .exe which was complaining about the very same error listed in the question. Go to Configuration Properties ("Project" menu, "Properties" menu item) and then click the C/C++, section, then the Preprocessor section under that, and then edit your Preprocessor Definitions so that NDEBUG is changed to _DEBUG (to match the setting in the exe).

    0 讨论(0)
  • 2020-11-29 21:28

    I had this problem as well.

    My problem was that I had copy/pasted the library include directories from my debug configurations.

    So project "Indep" was including static library "Dep.lib" from "../Debug", even in release. The fix was to change the library directory to "../Release" so I caught the release-built library rather than the previously-built debug library.

    0 讨论(0)
  • 2020-11-29 21:29

    If you would like to purposely link your project A in Release against another project B in Debug, say to keep the overall performance benefits of your application while debugging, then you will likely hit this error. You can fix this by temporarily modifying the preprocessor flags of project B to disable iterator debugging (and make it match project A):

    In Project B's "Debug" properties, Configuration Properties -> C/C++ -> Preprocessor, add the following to Preprocessor Definitions:

    _HAS_ITERATOR_DEBUGGING=0;_ITERATOR_DEBUG_LEVEL=0;

    Rebuild project B in Debug, then build project A in Release and it should link correctly.

    0 讨论(0)
提交回复
热议问题