1

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:

Matlab Config

And there is another configuration in vs 2017

VS Config

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.

Antoine Thiry
  • 2,362
  • 4
  • 28
  • 42
kwc
  • 21
  • 4
  • This linker error stops you from having to deal very nasty memory corruption errors. All of the object files and libraries must be built with the exact same settings. Most typical reason is to try link code that was compiled in the Debug configuration with code compiled with Release settings. The linker error tells you that it is test_cv_2.lib that caused the problem. – Hans Passant Dec 04 '18 at 09:49
  • Thanks, i will go seek for some feedback from MathWorks side as well, maybe there are some settings need to be preconfigured during the code generation stage – kwc Dec 05 '18 at 02:38
  • 1
    The corresponding post on MATLAB Answers for others interested in the same issue - https://www.mathworks.com/matlabcentral/answers/433888-matlab-coder-compiled-c-library-error-lnk2038-mismatch-detected-for-_iterator_debug_level-valu – ami91 Dec 05 '18 at 16:19
  • yup, thats me who asking the question in MATLAB Answers, but the staff do helpful on providing some useful guide – kwc Dec 06 '18 at 01:29

0 Answers0