Unable to compile MEX

Deadly 提交于 2019-12-12 00:17:59

问题


I am trying to compile some MATLAB MEX files from C++ source. The files I am trying to compile can be found here; I am using Windows XP on a 32-bit system, MATLAB 2012a and have installed the Microsoft Windows SDK v7.1 to use as my compiler.

MATLAB outputs the following error if I try to compile:

>> 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.

I have used mex -setup to setup my compiler with Microsoft Windows SDK v7.1. Interestingly, although I have them installed on my system, MATLAB doesn't see MS Visual Studio C++ 2008 or 2010. I have also tried compiling with the Lcc-win32 C 2.4.1 compiler (which is recognised by MATLAB), to the same effect as shown above.

I understand that this particular set of C++ source files might require something called liblo to compile (I'm not sure whether this is a requirement at compile-time or run-time); as far as I'm aware I have installed these correctly, but there's a possibility that the problem might lie here too.

Any help would be greatly appreciated.


回答1:


Try renaming your .c files to .cpp and re-compile

>> mex -largeArrayDims -O osc_free_address.cpp

Moreover, why don't you try the build m file that comes with the package (as suggested in this question)?

Have you downloaded and compiled liblo? you might need to add the include path and library path for it in the mex command?

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


来源:https://stackoverflow.com/questions/14853603/unable-to-compile-mex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!