How do I debug a MEX-file in Microsoft Visual C++ .NET 2003?

1 view (last 30 days)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 Apr 2019
Edited: MathWorks Support Team on 18 Apr 2019
This Solution is specific to the Microsoft Visual Studio .NET 2003 debugger on Windows.
NOTE: This solution is not officially supported by MathWorks.
The following steps demonstrate how to debug a MEX-file in the Microsoft Visual C++ .NET environment:
1. Open the Visual Studio .NET development environment.
2. Open a New "empty" project.
3. Select File->Add Existing Item... And select the name of the MEX-file DLL.
4. Select File->Add Existing Item... And select the name of the MEX-file source.
5. Open the MEX-file source by double-clicking on it in the Solution Explorer frame.
6. Place a break point at the appropriate line of code.
7. Select Project->$PROJECT_NAME settings where $PROJECT_NAME is the name of your project.
8. Under the Configuration Properties, click on "Debugging."
9. Click on "Command" under Action and browse to the MATLAB executable file $MATLABROOT/bin/win32/matlab.exe where $MATLABROOT is the directory in which MATLAB is installed.
10. Click OK.
11. Select Debug->Start or press F5.
12. Click NO if it prompts you to rebuild the out of date project.
13. Click "OK" if it reports that matlab.exe does not contain debugging symbols.
This should open the MATLAB environment after a few moments.
14. Change to the directory location of the MEX-file using the CD command in MATLAB
15. Execute the MEX-file normally. This will start the MSVS 7.0 environment and stop at the break point.
You should now be able to step through the MEX-file as you would any C/C++ applicaton.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!