User`s guide
Uses of the Compiler
1-9
Uses of the Compiler
The MATLAB Compiler (mcc) can translate M-files into C files. The resultant
C files can be used in any of the supported executable types including MEX,
executable, or library by generating an appropriate wrapper file. A wrapper file
contains the required interface between the Compiler-generated code and a
supported executable type. For example, a MEX wrapper contains the MEX
gateway routine that sets up the left- and right-hand arguments for invoking
the Compiler-generated code.
The code produced by the MATLAB Compiler is independent of the final target
type — MEX, executable, or library. The wrapper file provides the necessary
interface to the target type.
Note MEX-files generated by the MATLAB Compiler are not backward
compatible.
Creating MEX-Files
The MATLAB Compiler, when invoked with the -x macro option, produces a
MEX-file from M-files. The Compiler
1 Translates your M code to C code.
2 Generates a MEX wrapper.
3 Invokes the mex utility which builds the C MEX-file source into a MEX-file
by linking the MEX-file with the MEX version of the math libraries
(
libmatlbmx).
Figure 1-1, Developing MEX-Files, illustrates the process of producing a
MEX-file. The MATLAB interpreter dynamically loads MEX-files as they are
needed.