簡體   English   中英

MATLAB中的C ++ 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 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

已修改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嗎? 不幸的是我沒有在我的電腦上安裝Matlab,所以我只建議你嘗試用EDFFILE2.cpp手動編譯兩個.cpp文件edfMexImport.cppedfapi.lib

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM