Debug a mex function in Visual Studio

纵然是瞬间 提交于 2019-11-30 23:34:00

Turns out <MATLABROOT>\bin\matlab.exe actually runs <MATLABROOT>\bin\w64\matlab.exe. So if I ask Visual Studio to run that, breakpoints are triggered as expected.

Running MATLAB this way under the debugger is a lot slower than any other way, but at least now I can debug my code.

You could also run a MATLAB session as usual, and then attach Visual Studio to the running process. This is explained in more details in the documentation. Here is a quick summary:

  • compile the source MEX-file with debugging symbols enabled.
  • open the source C/C++ file in Visual Studio, and place a breakpoint.
  • start a normal MATLAB session. Then from Visual Studio, attach to the running matlab.exe process.
  • finally from MATLAB, run the MEX-function. You should hit the breakpoint with execution paused.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!