2012-11-28 26 views
2

我有一個與調試.mex32/.mex64文件相關的問題。現在假設我有一個名爲TEST.CPP文件:如何使用Visual Studio 2010調試MATLAB .mex32/.mex64文件

#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"); 
} 

然後我就可以編譯和MATLAB與Visual Studio 2010.Then建立test.mex64,我可以寫下面的腳本來測試功能:

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. 
+0

你可能想看看[這個問題](http://stackoverflow.com/questions/11220250/how-do-i-profile-a-mex-function-in-matlab/12405131#12405131)。它涉及在Linux上分析mex,但在Windows上應該使用類似的想法。無可否認,性能分析有點不同,但你可以從那裏開始。 – angainor

回答

1

我找到了解決方案:當我創建.mexw64函數(在我們的例子中是test.mexw64)時,我將它複製到MATLAB工作目錄中。爲了調試這個功能,將test.pdb文件複製到MATLAB工作目錄也很重要。這樣做後,我可以調試。

2

你建立與調試選項 「-g」 你MEX文件?

相關問題