如何使用Visual Studio 2010调试MATLAB .mex32/.mex64文件 [英] how to debug MATLAB .mex32/.mex64 files with Visual Studio 2010
问题描述
我有一个有关调试.mex32/.mex64文件的问题.假设现在我有一个名为test.cpp的文件:
I have a question related to debugging .mex32/.mex64 files. Suppose now I have a file named test.cpp:
#include "mex.h"
#include <iostream>
void mexFunction(int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
mexPrintf("Hello Matlab, and this is a test program\n");
}
然后我可以使用Visual Studio 2010编译和构建test.mex64
.然后在matlab中,我可以编写以下脚本来测试该功能:
I can then compile and build test.mex64
with Visual Studio 2010.Then in matlab, I can write the following script to test the function:
clc;
test;
现在假设我想调试test.mex64函数,该怎么办?已采用以下程序,但失败了:
Now suppose I want to debug the test.mex64 function, what should I do? The have adopted the following procedure, but failed:
- 在VS2010的行
mexPrintf
开头处切换断点. - 使用VS2010,从调试"->附加到进程"中选择MATLAB.exe.
- 运行MATLAB脚本
clc; test;
- Toggle break point at the begging of the line
mexPrintf
with VS2010. - With VS2010 from Debug->Attach to Process... select MATLAB.exe.
- Run MATLAB script
clc; test;
我获得的错误消息如下:
The error message I have obtained is as follows:
The breakpoint will not currently be hit. No symbols have been loaded for this document.
推荐答案
我找到了解决方案:创建.mexw64函数(在本例中为test.mexw64)时,我将其复制到了MATLAB工作目录中.为了调试此功能,将test.pdb文件也复制到MATLAB工作目录也很重要.完成之后,我可以进行调试.
I have found the solution: when I created the .mexw64 function (test.mexw64 in our case), I copied it to the MATLAB work directory. In order to debug this function, it is important to copy test.pdb file to the MATLAB work directory as well. After doing that, I can debug.
这篇关于如何使用Visual Studio 2010调试MATLAB .mex32/.mex64文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!