【问题标题】:how to debug MATLAB .mex32/.mex64 files with Visual Studio 2010如何使用 Visual Studio 2010 调试 MATLAB .mex32/.mex64 文件
【发布时间】:2012-11-28 17:28:40
【问题描述】:

我有一个与调试 .mex32/.mex64 文件有关的问题。假设现在我有一个名为 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 中,我可以编写以下脚本来测试功能:

clc; 
test;

现在假设我要调试 test.mex64 函数,我应该怎么做?已采用以下程序,但未通过:

  1. 使用 VS2010 在mexPrintf行的乞求处切换断点。
  2. 使用 VS2010 从 Debug->Attach to Process... 选择 MATLAB.exe。
  3. 运行 MATLAB 脚本clc; test;

我得到的错误信息如下:

The breakpoint will not currently be hit. No symbols have been loaded for this document. 

【问题讨论】:

  • 您可能想查看this question。它处理 Linux 上的 mex 分析,但类似的想法应该在 Windows 上使用。诚然,分析有点不同,但您可以从那里开始。

标签: matlab visual-c++


【解决方案1】:

您是否使用调试选项“-g”构建了 mex 文件?

【讨论】:

    【解决方案2】:

    我找到了解决方案:当我创建 .mexw64 函数(在我们的例子中为 test.mexw64)时,我将它复制到了 MATLAB 工作目录。为了调试此函数,将 test.pdb 文件复制到 MATLAB 工作目录也很重要。完成后,我可以调试。

    【讨论】:

      猜你喜欢
      • 2012-03-17
      • 1970-01-01
      • 1970-01-01
      • 2013-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-14
      相关资源
      最近更新 更多