MATLAB: Do I receive the error “Mex file entry point is missing?”

entryfileMATLAB Compilermexmexfunctionmissingpoint

When I try to compile my foo.c, I receive an error like the following:
Mex file entry point is missing. Please check the (case-sensitive)
spelling of mexFunction (for C MEX-files), or the (case-insensitive)
spelling of MEXFUNCTION (for FORTRAN MEX-files).
??? Invalid MEX-file

Best Answer

This error is due to the fact that "mexFunction" or the parameters may be incorrect. Make sure you have:
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
In order to have a valid mex source code, the above function needs to replace "main()" with "void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )"
For more information, see:
Under "Examples of C MEX-files".