External Interfaces/API    

MEX Script Switches

The mex script has a set of switches (also called options) that you can use to modify the link and compile stages. The MEX Script Switches table lists the available switches and their uses. Each switch is available on both UNIX and Windows unless otherwise noted.

For customizing the build process, you should modify the options file, which contains the compiler-specific flags corresponding to the general compile, prelink, and link steps required on your system. The options file consists of a series of variable assignments; each variable represents a different logical piece of the build process.

Table 1-3: MEX Script Switches  
Include the contents of the text file <rsp_file> as command line arguments to the mex script.
Perform argument checking on MATLAB API functions (C functions only).
Compile only; do not link.
Define C preprocessor macro <name> [as having value <def>]. (Note: UNIX also allows -D<name>[=<def>].)
-f <file>
Use <file> as the options file; <file> is a full pathname if it is not in current directory.
Build an executable with debugging symbols included.
Help; lists the switches and their functions.
Include <pathname> in the compiler include search path.
Inlines matrix accessor functions (mx*). The generated MEX-function may not be compatible with future versions of MATLAB.
(UNIX) Link against library lib<file>.
(UNIX) Include <pathname> in the list of directories to search for libraries.
Override options file setting for variable <name>. This option is equivalent to <ENV_VAR>#<val>, which temporarily sets the environment variable <ENV_VAR> to <val> for the duration of the call to mex. <val> can refer to another environment variable by prepending the name of the variable with a $, e.g., COMPFLAGS#"$COMPFLAGS -myswitch".
(UNIX) Override options file setting for variable <name>.
Build an optimized executable.
-outdir <name>
Place all output files in directory <name>.
-output <name>
Create an executable named <name>. (An appropriate executable extension is automatically appended.)
Set up default options file. This switch should be the only argument passed.
Undefine C preprocessor macro <name>.
Verbose; print all compiler and linker settings.
Compile MATLAB 5-compatible MEX-file.

  Custom Building MEX-Files Default Options File on UNIX