2013-02-13 251 views
0

我想從C++源代碼編譯一些MATLAB MEX文件。我正在編譯的文件can be found here;我在32位系統上使用Windows XP,MATLAB 2012a並安裝了Microsoft Windows SDK v7.1以用作我的編譯器。無法編譯MEX

>> mex -O -largeArrayDims osc_free_address.c 
osc_free_address.c 
osc_free_address.c(1) : error C2059: syntax error : '<' 
osc_free_address.c(37) : error C2015: too many characters in constant 
osc_free_address.c(38) : error C2059: syntax error : '<' 
osc_free_address.c(39) : error C2015: too many characters in constant 
osc_free_address.c(39) : error C2015: too many characters in constant 
osc_free_address.c(39) : error C2015: too many characters in constant 
osc_free_address.c(41) : error C2018: unknown character '0x40' 
osc_free_address.c(43) : error C2015: too many characters in constant 
osc_free_address.c(44) : error C2015: too many characters in constant 
osc_free_address.c(44) : error C2015: too many characters in constant 
osc_free_address.c(44) : error C2015: too many characters in constant 
osc_free_address.c(44) : error C2015: too many characters in constant 
osc_free_address.c(46) : error C2059: syntax error : '<' 
osc_free_address.c(82) : fatal error C1021: invalid preprocessor command 'page' 

    C:\PROGRA~1\MATLAB\R2012A\BIN\MEX.PL: Error: Compile of 'osc_free_address.c' failed. 

Error using mex (line 206) 
Unable to complete successfully. 

我用MEX -SETUP設置我的編譯器的Microsoft Windows SDK V7.1

MATLAB,如果我嘗試編譯器輸出下列錯誤。有趣的是,雖然我已經將它們安裝在我的系統上,但是MATLAB沒有看到MS Visual Studio C++ 2008 2010.我也嘗試編譯與Lcc-win32 C 2.4.1編譯器(其中被識別MATLAB),以達到與上面所示相同的效果。我知道這個特定的C++源文件集可能需要一些東西叫liblo來編譯(我不確定這是編譯時還是運行時的需求);據我所知,我已經正確安裝了這些設備,但這裏也有可能存在這個問題。

任何幫助將不勝感激。

回答

2

試試你.c文件重命名爲.cpp並重新編譯

>> mex -largeArrayDims -O osc_free_address.cpp 

而且,你爲什麼不嘗試自帶的包 (如this question建議)構建M檔?

你下載並編譯過liblo嗎?您可能需要在mex命令中爲其添加包含路徑和庫路徑?

>> mex -largeArrayDims -O -I<liblo include path> -L<liblo lib path> -llo osc_free_address.cpp 
+0

這會導致類似(但更長)的錯誤消息。至於使用'osc_make.m'文件,這根本不是'm'文件;它包含類似HTML/CSS的代碼。我不知道它的目的是什麼;如果我嘗試在MATLAB中運行,它會在#1行中引發錯誤。 – CaptainProg 2013-02-13 12:58:47

+0

['osc_make'](http://sourceforge.net/p/oscmex/code/4/tree/trunk/src/osc_make.m#l32)是一個有效的matlab代碼。然而,閱讀它的評論,它需要gnumex和mingw以及一些其他有關liblo編譯而不使用pthread的必要條件。 – Shai 2013-02-13 13:04:47

+1

似乎從SourceForge下載代碼提供了一個非常不同的文件,通過打開文件和複製內容獲得! – CaptainProg 2013-02-13 13:08:24