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]
I think the configuration may need to be setup from MATLAB coder as well:
0ZY3h.png
And there is another configuration in vs 2017
29vhN.png
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
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 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

产品


版本

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by