trouble with debug using Visual Studio 2008

I'm trying to debug some Fortran code, and I've followed the instructions at http://www.mathworks.com/help/techdoc/matlab_external/f32489.html#f18756 and have tried it with the yprime.c as suggested (after switching back to the C compiler, of course).
The Visual Studio hangs when I run the program. I'm using 2008 instead of 2005 but wouldn't expect this to be an issue. I'm operating 64-bit Matlab. My Visual Studio looks to be an x86 (32-bit) program, but I don't enough to know whether that is the source of the problem. I get the same problem with either the Fortran 11.1 compiler or the Microsoft Visual C++ 2010 Express compiler. Has anyone experienced a similar issue?

6 Comments

Did you compile yprime as -win32 or as -win64 ?
At what stage does VS hang exactly? Did you set a breakpoint at the very top of mexFunction() to see if any of the code is causing the issue (although this is unlikely because this is tried and tested example code)?
FYI - although VS is a 32-bit program by itself, you can install x64 compilers along with it to produce 64-bit binaries. If you are able to locate your compiler using "mex -setup" and produce a .mexw64 file, then you do have the x64 compilers.
yprime was compiled as -win64.
VS hangs as soon as I send the yprime(1,1:4) command in Matlab. The breakpoint indicator in VS, the open circle and exclamation point, does change to an arrow when I execute the Matlab command. But it immediately hangs and tells me there was an error and that it is shutting down. Unfortunately it doesn't actually shut down and I have to kill the VS process from the Processes Tab in the Ctrl+Alt+Del menu. Matlab never regains control, so I have to kill that from the Applications tab.
And yes, I did set the breakpoint at the very top of the mexFunction()...
thanks,
Doug
This seems like it could be a Visual Studio issue. Are you able to debug other C/C++ libraries/executables without any problems on the same installation of Visual Studio? (Also, when you compile yprime.c, make sure that you select the same version of Visual Studio using "mex -setup")
Also, FYI - since your original question was about debugging FORTRAN code, note that Visual Studio can only be used to debug C/C++ code. You could follow a similar process with a FORTRAN debugger however (I'm not a FORTRAN programmer, so have no advice on what debugger to use).
This information:
http://www.mathworks.com/help/techdoc/matlab_external/f28378.html
says that Microsoft Visual Studio tools can also be used to debug Fortran code. Is this bad information?
Is there a way to run the Fortran mex code (with the gateway function) directly from Visual Studio and still have access to Matlab functions? This page http://www.codeproject.com/KB/cpp/MatlabVS.aspx seems to indicate there is a way to do this for C code, but I'm not familiar enough with what preprocessor directives and .h files would need to be present to be able to do this in Fortran.

Sign in to comment.

Answers (0)

Categories

Asked:

on 7 Jun 2011

Community Treasure Hunt

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

Start Hunting!