C++ MATLAB 中的 MEX 编译
C++ MEX compilation in MATLAB
我正在尝试使用一个名为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 FILESMATLAB71BINMEX.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));
看起来缺少一些类型定义,尤其是mwSize
和mwIndex
类型。您可以将以下内容添加到EDFFile2.h并重试吗?
就在下面
#include "edf.h"
#include <mex.h>
添加这个:
#ifndef mwSize
#define mwSize int
#endif
#ifndef mwIndex
#define mwIndex int
#endif
MEX 文件已被修改以支持 64 位"大型数组处理 API",如本文档中所述:
http://www.mathworks.com/support/solutions/en/data/1-5C27B9/
请注意,此可选的大变量支持最初是在 R7.3 (2006b( 中添加的,您的版本甚至更旧。 基本上,您的 MATLAB 对于 MEX 文件使用的 API 来说太旧了。 也就是说,如果 MEX 文件足够简单,Gunther 的解决方案可能是将 MEX 文件"向后移植"到旧 MATLAB 的简单答案。 像 mxGetDimensions(( 这样的函数现在返回 mwSize*,但用于返回 int*。
因此,如果可以的话,请升级 MATLAB,否则请尝试 Gunther 的答案,让我们知道它是怎么回事。
你看过edfCompile.m的内部吗?不幸的是,我的PC上没有安装Matlab,所以我只能建议您尝试编译两个.cpp文件,edfMexImport.cpp
并使用edfapi.lib
手动EDFFILE2.cpp
- 使用 MEX 编译C++文件
- 使用 mex 编译库时出错 - __int 64 未命名类型
- complex_Bessel_function库的编译——与Fortran代码的链接——mex文件
- 使用 mkoctfile 与 Octave 和 Visual Studio 2010 编译器编译 .mex 或 .oct
- MEX 编译给出"there are no arguments to ... that depend on a template parameter"错误
- mex 编译错误: 无法识别的开关: -cxx
- 使用 mex 在 Matlab 中编译C++失败
- C++ MATLAB 中的 MEX 编译
- 在mex函数中使用OpenCV:编译后出错
- Matlab Mex代码未编译
- MATLAB + Mex + OpenCV:正确链接和编译,但在运行时找不到库
- MATLAB中的Myo臂章手势(无法编译.m或.mex文件)
- MATLAB MEX c++文件编译错误,找不到c++命令
- 使用Matlab R2011a在Ubuntu 11.04上编译Matlab mex文件时出错
- 试图用MATLAB的mex编译多个c++文件时出错
- 如何避免重复初始化.mex (matlab编译代码)
- 如何将 MATLAB 的 mex 设置定向到Microsoft Windows SDK 进行C++编译?(设置位置时出错)
- 在Matlab 2013a中编译并运行mex
- 在Visual Studio 2010中为从C文件编译的mex文件添加OpenMP支持
- 无法编译MEX