无法编译MEX

时间:2013-02-13 12:29:18

标签: c++ c matlab compiler-errors mex

我正在尝试从C ++源代码编译一些MATLAB MEX文件。我正在尝试编译的文件can be found here;我在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~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并没有看到MS Visual Studio C ++ 2008 2010.我也尝试使用 Lcc-win32 C 2.4.1进行编译编译器( 由MATLAB识别),效果如上所示。

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

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:2)

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

>> mex -largeArrayDims -O osc_free_address.cpp

此外,为什么不尝试包附带的build m文件 (如this question中所述)?

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

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