MATLAB: MEX: fatal error LNK1181: cannot open input file ‘Files\MAT​LAB\R2016b​\extern\li​b\win64\mi​crosoft libmx.lib

extermalinterfaceslinkingMATLABmex

Why do I receive the following error when trying to compile a mex file as follows?
 
>> mex -v arrayProduct.c '-LC:\Foo bar\lib\'
LINK : fatal error LNK1181: cannot open input file 'Files\MATLAB\R2016b\extern\lib\win64\microsoft libmx.lib libmex.lib libmat.lib
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
/out:arrayProduct.mexw64'

Best Answer

The trailing slash in the library include path is causing problems with the 'link' command being run at the command line. Remove the trailing slash from the library include path.
>> mex -v arrayProduct.c '-LC:\Foo bar\lib*\*'
becomes
>> mex -v arrayProduct.c '-LC:\Foo bar\lib'
This issue will occur with any mex file path inclusions (-I, -L, etc) which contain a path with spaces and a trailing backslash.
Related Question