MATLAB: Problem compiling mex files

compileMATLABMATLAB Compilermexwindows 7

The error I get is the following
compiling : ._bspline_error_2d_double.c -> Default options filename found in C:\Users\Orger\AppData\Roaming\MathWorks\MATLAB\R2012a —————————————————————- -> Options file = C:\Users\Orger\AppData\Roaming\MathWorks\MATLAB\R2012a\mexopts.bat MATLAB = C:\Program Files\MATLAB\R2012a -> COMPILER = cl -> Compiler flags: COMPFLAGS = /c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD OPTIMFLAGS = /O2 /Oy- /DNDEBUG DEBUGFLAGS = /Z7 arguments = Name switch = /Fo -> Pre-linking commands = -> LINKER = link -> Link directives: LINKFLAGS = /dll /export:mexFunction /LIBPATH:"C:\Program Files\MATLAB\R2012a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /MACHINE:X64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /manifest /incremental:NO /implib:"C:\Users\Orger\AppData\Local\Temp\mex_1feKKo\templib.x" /MAP:"_bspline_error_2d_double.mexw64.map" LINKDEBUGFLAGS = /debug /PDB:"_bspline_error_2d_double.mexw64.pdb" LINKFLAGSPOST = Name directive = /out:"_bspline_error_2d_double.mexw64" File link directive = Lib. link directive = Rsp file indicator = @ -> Resource Compiler = rc /fo "mexversion.res" -> Resource Linker = —————————————————————-
–> cl /c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD /FoC:\Users\Orger\AppData\Local\Temp\mex_1feKKo\.obj -I"C:\Program Files\MATLAB\R2012a\extern\include" /O2 /Oy- /DNDEBUG -DMX_COMPAT_32 ._bspline_error_2d_double.c
._bspline_error_2d_double.c ._bspline_error_2d_double.c : warning C4821: Unable to determine Unicode encoding type, please save the file with signature (BOM) ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x5' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x16' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x7' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x2' ._bspline_error_2d_double.c(1) : error C2061: syntax error : identifier 'OS' ._bspline_error_2d_double.c(1) : error C2059: syntax error : ';' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x2' ._bspline_error_2d_double.c(1) : error C2143: syntax error : missing '{' before 'constant' ._bspline_error_2d_double.c(1) : error C2059: syntax error : '<Unknown>' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0xe' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x2' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0xe' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1e' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0xe' ._bspline_error_2d_double.c(1) : error C2061: syntax error : identifier 'É~9' ._bspline_error_2d_double.c(1) : error C2059: syntax error : ';' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x15' ._bspline_error_2d_double.c(1) : error C2061: syntax error : identifier 'com' ._bspline_error_2d_double.c(1) : error C2059: syntax error : ';' ._bspline_error_2d_double.c(1) : error C2059: syntax error : '.' ._bspline_error_2d_double.c(1) : error C2021: expected exponent value, not 'b' ._bspline_error_2d_double.c(1) : error C2059: syntax error : 'bad suffix on number' ._bspline_error_2d_double.c(1) : error C2059: syntax error : 'constant' ._bspline_error_2d_double.c(1) : error C2143: syntax error : missing '{' before '-' ._bspline_error_2d_double.c(1) : error C2059: syntax error : '-' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1e' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1e' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1c' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1e'
C:\PROGRA~1\MATLAB\R2012A\BIN\MEX.PL: Error: Compile of '._bspline_error_2d_double.c' failed.
I have tried using Matlab R2012A with Microsoft SDK as the compiler, and I also tried on another computer R2010A using Visual C++ 2010 Express and got the same error. I also tried adding a BOM to the file bspline_error_2d_double.c which didn't seem to fix the problem (maybe it is another file that needs a BOM?).
Thank you to anyone who can help. This is quite frustrating, and I have not been able to find anyone with a similar problem by googling.

Best Answer

PROBLEM SOLVED: It turns out the problem was that I had first downloaded the packages on a Mac and then copied them onto the Windows machine. Somewhere along the line, hidden files (with the prefix ._) with the .c extension were added to the folders by the Mac, and the windows compiler was trying unsuccessfully to read them. When I redownloaded the packages on the windows machine, everything was good.