How do I debug a MATLAB 6.5 (R13) MEX file in MSVC?

1 view (last 30 days)
I would like to debug a MEX-file I compiled in MATLAB 6.5 (R13) in the MSVC environment.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
In MATLAB 6.5 (R13), you can use the MATLAB Add-In for Visual Studio to set up a project for debugging your MEX file.
If you do not have the add-in setup, see the solutions attached at the bottom of this page.
Now, to debug your MEX file:
1. Start Visual C++.
2. From the menu bar, select File / New.
3. Select a Visual MATLAB project type.
4. Select C MEX as Application Type. Press Finish.
From there you can add your files to the project.
Then finally to compile and debug:
a. To compile, first save your code
b. Select Build->Build MEX_Project.dll
Your .dll should now be ready to run in MATLAB.
To debug your .dll
a. Save your code
b. Place breakpoints in your code
c. Select Build->Debug->Go
You will be prompted to enter the executable to be used for debugging, since you are debugging
a .dll. You should enter $MATLAB\bin\matlab.exe, where $MATLAB is the directory in which
MATLAB is installed. Click OK, and a debugging session will start.
d. Once inside the MATLAB session, type the name of your MEX file (with possibly the required arguments). This should bring you into the MSVC debugger. Please refer to the MSVC manual for more information about debugging.

More Answers (0)

Categories

Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!