c++ - Mex 文件执行时出错,Matlab 窗口

标签 c++ c matlab mex

我一直在尝试在matlab中编译一些mex文件。该文件编译良好,但在我运行它时抛出以下错误。

Invalid MEX-file 'filename.mexw32': The specified procedure could not be found.

我已将原因缩小到代码中使用的函数push_back()。代码片段如下。

typedef vector<node> node_list;

node_list q;...

node n;

n.id         = 0;

n.parent     = -1;


  n.is_leaf    = 0; // <- set to 1 if node symbol is a terminal

  n.rhs_index  = 0;

  n.symbol     = ctx.start_symbol;

  n.rule_index = 0; // <- set after computing argmax rule

  n.rhs_index  = 0;

  n.x          = start_x;

  n.y          = start_y;

  n.l          = start_l;

  n.ds         = 0;

  n.dx         = 0; // <- set if def rule

  n.dy         = 0; // <- set if def rule

  n.score      = start_score;

  n.loss       = 0; // <-- set if start symbol

  q.push_back(n);

最后一行 q.push_back(n); 导致了错误。

我已经包含了头文件

mex.h、 vector 、iostream 和列表

如何解决这个问题?我应该在代码中定义方法push_back吗?如果是的话我该怎么办?我是 c++ 的初学者。任何帮助将不胜感激。

最佳答案

每个 mex 文件都需要一个入口点,这是一个名为“mexFunction”的函数。

名称“mexFunction”及其签名是固定的,对于所有 mex 函数都相同,但 matlab 将使用文件名来识别它们。

据我所知,您无法以脚本样式运行 mex。

常见的做法是将代码编写为 C 函数,然后在“mexFunction”中调用该 C 函数。

关于c++ - Mex 文件执行时出错,Matlab 窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27741994/

相关文章:

c++ - curl 回调未返回相同数量的字节

c++ - 降低时间复杂度

c - 函数返回类型的名称作为用户定义数据类型的名称

matlab - 多个(超过 2 个)数字的最大公约数

image - 在 MATLAB 中播放图像序列

c++ - 调试 COM 免费注册 (c++)

c++ - 如何使用vector和struct?

user-interface - 交互式操作Matlab图形上的矩形

c++ - 如何将参数传递给 C++ 中的基类构造函数

c - 打开文件时出错