MATLAB Answers

Unable to debug C-MEX source files under Matlab R2017b and Visual Studio Community 2017

2 views (last 30 days)
Yunhui Zhou
Yunhui Zhou on 7 Aug 2018
Answered: Ran Chen on 9 Aug 2018
Hi, I am recently writing C-MEX files but I find I am unable to debug the code. I use Matlab R2017b and Visual Studio Community 2017, and follow the debug instructions in here (specify '-g' option when compiling, attach MATLAB process to Visual Studio, and set breakpoints), but when I run the mex file, it just went through all the breakpoints and produce the result, not pausing at any of the breakpoints.
I wish to know how to solve this problem? Did I miss some steps?
Microsoft Visual C++ (2017) is the only compiler I have installed. And here is the installed components. Did I miss some components?

  0 Comments

Sign in to comment.

Answers (1)

Ran Chen
Ran Chen on 9 Aug 2018
Hello,
I understand that you are unable to reach the breakpoint in Visual Studio. Unfortunately, I cannot reproduce the issue on my end. MATLAB R2017b supports debugging with the Visual Studio Community 2017, and it seems that you have all the proper tools installed.
The process you run the code using command in MATLAB should work the same as you click the run button in the Visual Studio in debug mode. Please make sure of the following:
1. Please make sure you are compiling the MEX file using the ‘-g’ flag.
2. Please make sure you are attaching the correct MATLAB process that is used to execute the MEX file.
3. Please check whether breakpoints are set in lines which are reachable at runtime.
If you still experiencing the issue, you may consider getting more information from the Visual Studio support team.

  0 Comments

Sign in to comment.

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by