【发布时间】:2019-07-23 15:06:43
【问题描述】:
每当我尝试编译我的非常简单的测试 mex 函数时,都会出现错误
“未定义对 `mxGetDoubles' 的引用
collect2.exe:错误:ld 返回 1 个退出状态
我正在使用 Matlab R2019a,mingw-w64 6.3.0。他们提供的示例 c 文件 (explore.c) 编译得很好,并且还使用了mxGetDoubles()。
我尝试过使用mxGetPr(),尽管他们说他们不推荐它,并且在文档中的 matlab R2018a 之后它不应该工作,但效果很好。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mex.h"
#include "matrix.h"
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){
mxDouble *vertices;
vertices = mxGetDoubles(prhs[1]);//mxGetPr(prhs[1]);
}
【问题讨论】:
-
消息似乎不是来自编译器本身,而是来自链接器(意思是:缺少库)或来自加载器(意思是:缺少 dll)。
-
@PaulOgilvie 当我调用 ``` mex fileName.c `` 时出现 matlab 错误,但同样奇怪的是,旧函数和使用相同函数的示例 c 文件两者都有效。
-
好像和32/64位有关系,但我没找到解决办法。
-
@AnderBiguri 我刚刚使用“mex -R2018a fileName.c”进行了尝试,并且编译没有错误。我现在只是在测试它,看看它是否真的有效。它可能与matlab交错API有关