MATLAB: How to compile a MEX program that contains MAT-file routines using the gcc compiler

externalfileinterfaceinterfacesmatmatcreatmatcreat.cMATLAB

I want to compile a MEX program that contains MAT-file routines using the gcc compiler outside of MATLAB.

Best Answer

In order to compile a MEX program that contains MAT-file routines using gcc, you need to read through the $MATLAB/bin/matopts.sh options file, (where $MATLAB is the MATLAB root directory on your machine, as returned by typing
matlabroot
at the MATLAB Command Prompt.) and specify equivalent options for gcc. Note that compiling a MEX program that contains MAT-file routines outside of MATLAB is not supported.
Related Question