Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to debug (step run) a mex file(mexw32 or dll file) in MSVC / visual studio 2008 express edition

1,000 views
Skip to first unread message

SKS

unread,
Sep 3, 2009, 6:57:57 AM9/3/09
to
Please follow following steps

0.Creat your dll or mexw32 file using the option make -g or mex -g
filename.c
1.Close every thing(to make it fast .. not mandatory though
2.Open MSVC 2008 Express Edition
3.Open Matlab
4.From MS VC 2008 Go To Tools->Attach To Process (If this option does
n't show up repeat step 1 and it will :)
5.In Attach to process, select MATLAB.exe (Native code option is
selected by default. If it is not select it manually)
6.From VC IDE, go to File->Open->File and select the file having
mexFunction(testmex.c in my case)
7.Put Breakpoints ar required lines(it will show warning that the code
may not hit the breakpint as the symbols for this are not loaded)
Ignore the warning.
8.Run your simulation (It will be good to put a breakpoint in Matlab
code line in which we call the mex func.
9.Run the code and it will hit the breakpoint...now we can step
execute it.

hoda....@gmail.com

unread,
Jan 21, 2014, 6:12:56 PM1/21/14
to
I did all these step but I'm getting "No source available" error! It's strange because I was able to debug it before. Do you have any suggestion?
I'm using Visual Studio 2010 and MATLAB 2010a

vinh.n...@gmail.com

unread,
Jan 21, 2014, 7:25:13 PM1/21/14
to
in step 5, make sure you choose Native code option. That will solve your problem
Message has been deleted

ehti...@gmail.com

unread,
Apr 7, 2014, 8:47:16 AM4/7/14
to
hello, I am facing a problem that when I try to run the matlab builtin function shown on this site, http://www.mathworks.co.uk/help/simulink/sfg/debugging-c-mex-s-functions.html the simulink runs and the response is generated without moving into the debugging environment? Any idea why this happened?
0 new messages