MATLAB coder compiled C++ library error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
3 次查看(过去 30 天)
显示 更早的评论
Hi,
I tried to use a MATLAB coder compiled C++ library in vs 2017 but encountered the error below:
1> test_cv_2.lib(test_cv_2.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1> test_cv_2.lib(test_cv_2.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
1> LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library [1]
From my initial search in the web and i have look through this post: error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
I think the configuration may need to be setup from MATLAB coder as well:

And there is another configuration in vs 2017

Anyone have any idea on the correct settings based on the images above? Or is there any extra settings need to be done?
I have tried out several settings but the same error occur, for example, set Build configuration set to debug in MATLAB coder environment and Multi-threaded Debug DLL (/MDd) in vs 2017 setting.
Thank you.
4 个评论
Mukund Sankaran
2018-12-6
As far as I'm aware, there is no readily available documentation on how to modify those settings in the MATLAB Coder app. We will consider adding this information to the documentation.
You could start by looking at the compiler/linker flags in the "Command Line" section of the C/C++ configuration properties in Visual Studio, and map them to the ones used in MATLAB Coder. If you open the Makefile for your MATLAB Coder project (this resides under the codegen folder, and is typically named <project>_rtw.mk), you can see the values being used for the flags specified in the toolchain options table.
Alternatively, if you do not need precompiled code from MATLAB coder, you can generate code only by choosing "Source Code" as the build type in the Generate Code step. You can then compile all your code in Visual Studio, which would eliminate the need to tweak the toolchain options.
Hope this helps.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!