MATLAB Answers

Cannot debug mex file with Microsoft Visual C++ 2013 Professional

33 ビュー (過去 30 日間)
Vincent
Vincent 2015 年 4 月 1 日
コメント済み: Janosch Kunczik 2018 年 3 月 8 日
I tried to debug a mex file, with, exactly as described in the Matlab documentation on Debugging on Microsoft Windows Platforms .
The mex files compiles well and the .pdb file is created. I then attach Visual studio to Matlab, set a breakpoint and run the mex file. However my breakpoint is ignored.
Any clue on how to get this working? Thanks!
Some debug info:
mex -setup
MEX configured to use 'Microsoft Visual C++ 2013 Professional (C)' for C language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the
new API. You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
To choose a different C compiler, select one from the following:
Microsoft Visual C++ 2013 Professional (C) mex -setup:C:\Users\Me\AppData\Roaming\MathWorks\MATLAB\R2014b\mex_C_win64.xml C
Microsoft Windows SDK 7.1 (C) mex -setup:'C:\Program Files\Matlab\R2014b\bin\win64\mexopts\winsdk-7.1_c.xml' C
To choose a different language, select one from the following:
mex -setup C++
mex -setup FORTRAN
step 1:
cc = mex.getCompilerConfigurations('C','Selected');
cc.Name
ans =
Microsoft Visual C++ 2013 Professional (C)
Step 2:
>> mex -g -v yprime.c
Verbose mode is on.
Neither -compatibleArrayDims nor -largeArrayDims is selected.
Using -compatibleArrayDims. In the future, MATLAB will require the use of
-largeArrayDims and remove the -compatibleArrayDims option.
For more information:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
... Looking for compiler 'Microsoft Visual C++ 2013 Professional (C)' ...
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 12.0 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 12.0 ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' 12.0 ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio 12.0\').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\cl.exe' ...Yes.
... Looking for folder 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC' ...Yes.
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1' InstallationFolder ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1' InstallationFolder ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1' InstallationFolder ...Yes ('C:\Program Files (x86)\Windows Kits\8.1\').
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 12.0 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 12.0 ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' 12.0 ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio 12.0\').
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VC7' 12.0 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\VisualStudio\SxS\VC7' 12.0 ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VC7' 12.0 ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\').
... Looking for environment variable 'VS120COMNTOOLS' ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe' ...Yes.
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 12.0 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 12.0 ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' 12.0 ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio 12.0\').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat' ...Yes.
... Looking for folder 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC' ...Yes.
Found installed compiler 'Microsoft Visual C++ 2013 Professional (C)'.
Set PATH = C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\Bin\amd64;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\Bin\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\..\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\..\Common7\Tools;C:\Program Files (x86)\Windows Kits\8.1\\Bin\x64;C:\Program Files (x86)\Windows Kits\8.1\\Bin\x86;;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Matlab\R2014b\runtime\win64;C:\Program Files\Matlab\R2014b\bin;C:\Program Files\Matlab\R2014a\runtime\win64;C:\Program Files\Matlab\R2014a\bin;C:\Program Files\Matlab\R2014a\polyspace\bin;C:\Program Files\TortoiseSVN\binC:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x64;C:\Program Files (x86)\OpenSSH\bin;C:\Program Files (x86)\MATLAB Compiler Runtime 7.9\v79\runtime\win32;C:\Program Files\ffmpeg-20140826-git-96b2ba6-win64-static\bin;C:\Program Files (x86)\MiKTeX 2.9\miktex\bin\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Matlab\R2014b\polyspace\bin
Set INCLUDE = C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\ATLMFC\INCLUDE;C:\Program Files (x86)\Windows Kits\8.1\\include\shared;C:\Program Files (x86)\Windows Kits\8.1\\include\um;C:\Program Files (x86)\Windows Kits\8.1\\include\winrt;C:\Program Files\Matlab\R2014b\extern\include;
Set LIB = C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\Lib\amd64;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\ATLMFC\Lib\amd64;C:\Program Files (x86)\Windows Kits\8.1\\lib\winv6.3\um\x64;C:\Program Files\Matlab\R2014b\lib\win64;
Set LIBPATH = C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\Lib\amd64;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\ATLMFC\Lib\amd64;
Options file details
-------------------------------------------------------------------
Compiler location: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\..\
Options file: C:\Users\Me\AppData\Roaming\MathWorks\MATLAB\R2014b\mex_C_win64.xml
CMDLINE100 : cl /c /Zp8 /GR /W3 /EHs /nologo /MD /Z7 /DMX_COMPAT_32 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE -I"C:\Program Files\Matlab\R2014b\extern\include" -I"C:\Program Files\Matlab\R2014b\simulink\include" C:\Users\Me\Documents\MATLAB\kw\yprime.c /FoC:\Users\Me\AppData\Local\Temp\mex_70575166361078_10668\yprime.obj
CMDLINE200 : link /nologo /manifest /DLL /debug /PDB:"yprime.mexw64.pdb" /EXPORT:mexFunction C:\Users\Me\AppData\Local\Temp\mex_70575166361078_10668\yprime.obj /LIBPATH:"C:\Program Files\Matlab\R2014b\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /out:yprime.mexw64
CMDLINE250 : mt -outputresource:yprime.mexw64;2 -manifest yprime.mexw64.manifest
CMDLINE300 : del C:\Users\Me\AppData\Local\Temp\mex_70575166361078_10668\yprime.obj yprime.exp yprime.lib yprime.mexw64.manifest yprime.ilk
COMPILER : cl
COMPFLAGS : /Zp8 /GR /W3 /EHs /nologo /MD
COMPDEFINES : /DMX_COMPAT_32 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE
MATLABMEX : /DMATLAB_MEX_FILE
OPTIMFLAGS : /O2 /Oy- /DNDEBUG
INCLUDE : -I"C:\Program Files\Matlab\R2014b\extern\include" -I"C:\Program Files\Matlab\R2014b\simulink\include"
DEBUGFLAGS : /Z7
LINKER : link
LINKFLAGS : /nologo /manifest
LINKTYPE : /DLL
LINKEXPORT : /EXPORT:mexFunction
LINKLIBS : /LIBPATH:"C:\Program Files\Matlab\R2014b\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
LINKDEBUGFLAGS : /debug /PDB:"yprime.mexw64.pdb"
LINKOPTIMFLAGS :
OBJEXT : .obj
LDEXT : .mexw64
SETENV : set COMPILER=cl
set COMPFLAGS=/c /Zp8 /GR /W3 /EHs /nologo /MD /DMX_COMPAT_32 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /DMATLAB_MEX_FILE
set OPTIMFLAGS=/O2 /Oy- /DNDEBUG
set DEBUGFLAGS=/Z7
set LINKER=link
set LINKFLAGS=/nologo /manifest /export:%ENTRYPOINT% /DLL /LIBPATH:"C:\Program Files\Matlab\R2014b\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /EXPORT:mexFunction
set LINKDEBUGFLAGS=/debug /PDB:"%OUTDIR%%MEX_NAME%.mexw64.pdb"
set NAME_OUTPUT=/out:"%OUTDIR%%MEX_NAME%%MEX_EXT%"
VCROOT : C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC
SDKROOT : C:\Program Files (x86)\Windows Kits\8.1\
VSINSTALLDIR : C:\Program Files (x86)\Microsoft Visual Studio 12.0\
VCINSTALLDIR : C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\
PROF_ENV : C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe
VCVARSALLDIR : C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC
MATLABROOT : C:\Program Files\Matlab\R2014b
ARCH : win64
SRC : C:\Users\Me\Documents\MATLAB\kw\yprime.c
OBJ : C:\Users\Me\AppData\Local\Temp\mex_70575166361078_10668\yprime.obj
OBJS : C:\Users\Me\AppData\Local\Temp\mex_70575166361078_10668\yprime.obj
SRCROOT : C:\Users\Me\Documents\MATLAB\kw\yprime
DEF : C:\Users\Me\AppData\Local\Temp\mex_70575166361078_10668\yprime.def
EXP : yprime.exp
LIB : yprime.lib
EXE : yprime.mexw64
ILK : yprime.ilk
MANIFEST : yprime.mexw64.manifest
TEMPNAME : yprime
EXEDIR :
EXENAME : yprime
OPTIM : /Z7
LINKOPTIM : /debug /PDB:"yprime.mexw64.pdb"
-------------------------------------------------------------------
Building with 'Microsoft Visual C++ 2013 Professional (C)'.
cl /c /Zp8 /GR /W3 /EHs /nologo /MD /Z7 /DMX_COMPAT_32 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE -I"C:\Program Files\Matlab\R2014b\extern\include" -I"C:\Program Files\Matlab\R2014b\simulink\include" C:\Users\Me\Documents\MATLAB\kw\yprime.c /FoC:\Users\Me\AppData\Local\Temp\mex_70575166361078_10668\yprime.obj
yprime.c
link /nologo /manifest /DLL /debug /PDB:"yprime.mexw64.pdb" /EXPORT:mexFunction C:\Users\Me\AppData\Local\Temp\mex_70575166361078_10668\yprime.obj /LIBPATH:"C:\Program Files\Matlab\R2014b\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /out:yprime.mexw64
Creating library yprime.lib and object yprime.exp
mt -outputresource:yprime.mexw64;2 -manifest yprime.mexw64.manifest
Microsoft (R) Manifest Tool version 6.3.9600.16384
Copyright (c) Microsoft Corporation 2012.
All rights reserved.
del C:\Users\Me\AppData\Local\Temp\mex_70575166361078_10668\yprime.obj yprime.exp yprime.lib yprime.mexw64.manifest yprime.ilk
MEX completed successfully.
The created files:
>> ls
. .. yprime.c yprime.mexw64 yprime.mexw64.pdb
Step 5:
Step 6/7:
Step 8:
>> yprime(1,1:4)
ans =
2.0000 8.9685 4.0000 -1.0947
>> which yprime
C:\Users\Me\Documents\MATLAB\kw\yprime.mexw64
Step 9:
I'd like to end up here :D

  0 件のコメント

サインイン to comment.

採用された回答

Philip Borghesani
Philip Borghesani 2015 年 4 月 2 日
I see two possible issues. The first is that Visual Studio is attached to MATLAB as 'Managed' note the select button in your first screen capture. To debug a mex file you must debug with 'Native', this may fix the second issue that no symbols were loaded. If not then you will need to go into the modules dialog and force the symbols to load or figure out why they are not loading.

  2 件のコメント

Vincent
Vincent 2015 年 4 月 2 日
Thank you Philip, this was indeed the problem!
So for anybody else with this problem, don't use the default settings but check native only. It would be nice if Mathworks could add this to their documentation.
Janosch Kunczik
Janosch Kunczik 2018 年 3 月 8 日
Thank you Philip. That was the solution, I was looking for. I am using with Visual Studio 2015. Maybe the "Debug on Microsoft Windows Platforms" help page should be updated with this valuable information, as well.

サインイン to comment.

その他の回答 (0 件)

サインイン してこの質問に回答します。


Translated by