MATLAB 中的 C++ MEX 编译

标签 c++ matlab mingw mex

我正在尝试使用一个名为 edfImport 的函数(可在此处获得:http://kobi.nat.uni-magdeburg.de/edfImport)

为了使用该功能,我必须首先运行 edfCompile(包含在工具包中)。运行 edfCompile 时,出现错误:

??? Error using ==> mex
Unable to complete successfully

我正在运行 MATLAB 7.1 (R14) 并为我的编译器安装了最新版本的 MinGW、Cygwin 和 Gnumex(根据此页面上的说明:http://ptolemy.eecs.berkeley.edu/ptolemyII/ptII4.0/cygwin.htm)

我能够编译示例 mex 文件,但我仍然不相信这不是我的编译器设置方式的问题。感谢收到任何提示。很高兴知道是否还有其他人在运行 edfCompile 时遇到问题......(http://kobi.nat.uni-magdeburg.de/edfImport)

非常感谢

编辑:完整的错误信息:

In file included from edfMexImport.cpp:6:0: 
EDFFile2.h:37:39: error: 'mwSize' has not been declared 
EDFFile2.h:127:45: error: 'mwIndex' has not been declared 
edfMexImport.cpp: In function 'void mexFunction(int, mxArray**, int, const mxArray**)': 
edfMexImport.cpp:12:3: error: 'mwSize' was not declared in this scope 
edfMexImport.cpp:12:10: error: expected ';' before 'OutputDims' 
edfMexImport.cpp:48:12: error: expected ';' before 'OptionsDimN' 
edfMexImport.cpp:49:9: error: 'OptionsDimN' was not declared in this scope 
edfMexImport.cpp:51:13: error: 'OptionsDim' was not declared in this scope 
edfMexImport.cpp:51:33: error: expected primary-expression before ')' token 
edfMexImport.cpp:51:34: error: expected ';' before 'mxGetDimensions' 
edfMexImport.cpp:73:12: error: expected ';' before 'FlagsDimN' 
edfMexImport.cpp:74:9: error: 'FlagsDimN' was not declared in this scope 
edfMexImport.cpp:76:13: error: 'FlagsDim' was not declared in this scope 
edfMexImport.cpp:76:31: error: expected primary-expression before ')' token 
edfMexImport.cpp:76:32: error: expected ';' before 'mxGetDimensions' 

C:\PROGRAM FILES\MATLAB71\BIN\MEX.PL: Error: Compile of 'edfMexImport.cpp' failed. 

??? Error using ==> mex
Unable to complete successfully

Error in ==> edfCompile at 15
eval(sprintf('mex -I''%s'' edfMexImport.cpp EDFFILE2.cpp ''%s/edfapi.lib''', edfapiIncludesFolder, edfapiLibraryFolder));

最佳答案

似乎缺少某些类型定义,尤其是 mwSizemwIndex 类型。 您可以将以下内容添加到 EDFFile2.h 并重试吗?

就在下面

#include "edf.h"
#include <mex.h>

添加这个:

#ifndef mwSize
    #define mwSize int
#endif

#ifndef mwIndex
    #define mwIndex int
#endif

关于MATLAB 中的 C++ MEX 编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10657335/

相关文章:

matlab - 确定一个集合是否是另一个集合的子集的有效代码

matlab - 设置不同的刻度长度

c - Mingw 和 make 变量

c - 数据类型大小是否因计算机而异?

c++ - 使用#pragma detect_mismatch 确保 DLL 使用正确的静态链接库

c++ - 为什么这个随机生成器总是输出相同的数字

matlab - 删除包含特定范围之外的任何数字的行 - MATLAB

c++ - 如何使用 MinGW 编译 C++ std::thread 代码?

c++ - 为成员函数生成必要的引用限定重载

c++ - 一个 lambda 的返回类型可以通过返回值来推断,那么为什么不能是一个函数呢?