Getting Help When MEX Fails
To help diagnose compiler set up and build errors, call mex with
the verbose option, -v. For an example of the information
mex provides, type the following commands from a writable
folder:
copyfile(fullfile(matlabroot,'extern','examples','refbook','timestwo.c'),'.','f') mex -v timestwo.c
Errors Finding Supported Compiler
In verbose mode, mex displays the steps used to find a
supported compiler and to determine if it is properly installed. Each step begins
with the following text:
... Looking for
If the compiler is not configured properly, these messages show you the expected values for specific files, paths, and variables in the configuration.
If the compiler is found, mex displays a message similar
to:
Building with 'Microsoft Visual C++ 2012 (C)'.
Errors Building MEX Function
After locating the installed compiler, indicated by the “Building
with” message, verbose mode displays the compile and link commands
mex passes to the build tools. For example, the compile
command on Windows® platforms might be similar to the following:
cl /c /GR /W3 /EHs /nologo /MD /DMX_COMPAT_32 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE -I"matlabroot\extern\include" -I"matlabroot\simulink\include" /O2 /Oy- /DNDEBUG C:\work\mex\timestwo.c /FoC:\work\timestwo.obj timestwo.c
mex displays error messages from the compiler build tools.
For information about errors and warnings, see your compiler or language reference
documentation.
If you have experience with program development and want to modify a command
parameter, use the mex
varname=varvalue option.
Preview mex Build Commands
To display the build command details without executing the commands, type:
mex -n timestwo.c