无法编译MEX

Unable to compile MEX

本文关键字:MEX 编译      更新时间:2023-10-16

我正在尝试从C++源代码编译一些MATLAB MEX文件。我试图编译的文件可以在这里找到;我在32位系统MATLAB 2012a上使用Windows XP,并安装了Microsoft Windows SDK v7.1作为我的编译器。

如果我尝试编译,MATLAB会输出以下错误:

>> 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~1MATLABR2012ABINMEX.PL: Error: Compile of 'osc_free_address.c' failed. 
Error using mex (line 206)
Unable to complete successfully.

我已经使用mex-setup来设置我的编译器MicrosoftWindowsSDKv7.1。有趣的是,尽管我在系统上安装了它们,但MATLAB没有看到MSVisualStudioC++20082010。我还尝试过使用Lcc-win32C2.4.1编译器进行编译(被MATLAB识别为),效果如上所示。

我知道这组特定的C++源文件可能需要一个名为liblo的东西来编译(我不确定这是编译时还是运行时的要求);据我所知,我已经正确安装了这些,但问题可能也存在。

如有任何帮助,我们将不胜感激。

尝试将.c文件重命名为.cpp并重新编译

>> mex -largeArrayDims -O osc_free_address.cpp

此外,为什么不尝试该包附带的build m文件呢(如本问题所述)?

你下载并编译了liblo吗?您可能需要在mex命令中为其添加include路径和库路径?

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