Error while compiling mex wrapper in debug mode

14 ビュー (過去 30 日間)
Kishore
Kishore 2012 年 7 月 9 日
コメント済み: DanielFromIllinois 2021 年 9 月 30 日
Hello, i am using MATLAb 2011 b 32 bit . and MSVC 2011 EXpress edition. ( SDK 7.0)
1) Now, i have 3 static libraries built in Release mode. When i compile and link them, i see no issue, everything works fine.
2) But when the compile the mex wrapper ( when the libraries are in debug mode), i get an error test1.lib( test.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in mexWrapper.obj .
Then i defined _ITERATOR_DEBUG_LEVEL = 2 in mexWrapper.cpp. But then i get a new compiler error
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\yvals.h(113) : fatal error C1189: #error : _ITERATOR_DEBUG_LEVEL > 1 is not supported in release mode.
My question is, do i need to define something in the build options for debug mode?
Currently i am using
'mex -win32 -g -v -Dmex ', ...
'-D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE ', ...
'-D_CRT_SECURE_NO_WARNINGS ', ...
'LINKFLAGS="$LINKFLAGS /NODEFAULTLIB:MSVCRTD" ', ...
'CFLAGS="$CFLAGS -std=c99" '...
];
Please let me know anything that could help me build this.
Thanks!, Kishore.
  1 件のコメント
Kishore
Kishore 2012 年 7 月 10 日
any answers please?

サインインしてコメントする。

回答 (2 件)

Kaustubha Govind
Kaustubha Govind 2012 年 8 月 6 日
Instead of modifying mexWrapper.cpp, perhaps you should modify mexopts.bat to define _ITERATOR_DEBUG_LEVEL=2 and _SECURE_SCL=1. This will require the program to be compilied in debug mode (not in release mode). This is accomplished by including _DEBUG as another compiler flag. An example of the line defining COMPFLAGS in the mexopts.bat file follows:
COMPFLAGS=/c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE / D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=1 /D_ITERATOR_DEBUG_LEVEL=2 / DMATLAB_MEX_FILE /nologo /MD /D_DEBUG
  1 件のコメント
DanielFromIllinois
DanielFromIllinois 2021 年 9 月 30 日
Is there someplace to find documentation on these flags? Is it part of the compiler's documentation or matlab's mex or what?
Also, I didn't have a mexopts.bat file instead I had a mex_C++_win64.xml that I think is because i'm using VS2019 C++ compilers.

サインインしてコメントする。


Boyang
Boyang 2013 年 12 月 7 日
Hi, I ran into a similar problem. After setting both flags, I'm still seeing the error.
my mexopts.bat file:
set COMPFLAGS=/c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=1 /D_ITERATOR_DEBUG_LEVEL=2 /DMATLAB_MEX_FILE /nologo /MTd /D_DEBUG set OPTIMFLAGS=/O2 /Oy- /DNDEBUG
error message:
blitz.lib(globals.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in qobj.obj blitz.lib(globals.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MTd_StaticDebug' in qobj.obj Creating library C:\Users\boyangz\AppData\Local\Temp\mex_RK2lbn\templib.x and object C:\Users\boyangz\AppData\Local\Temp\mex_RK2lbn\templib.exp LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library qobj.mexw64 : fatal error LNK1319: 2 mismatches detected
C:\PROGRA~1\MATLAB\R2012B\BIN\MEX.PL: Error: Link of 'qobj.mexw64' failed.

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by