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  
Switch
Function
@<rsp_file>
Include the contents of the text file <rsp_file> as command line arguments to the mex script.
-argcheck
Perform argument checking on MATLAB API functions (C functions only).
-c
Compile only; do not link.
-D<name>[#<def>]
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.
-g
Build an executable with debugging symbols included.
-h[elp]
Help; lists the switches and their functions.
-I<pathname>
Include <pathname> in the compiler include search path.
-inline
Inlines matrix accessor functions (mx*). The generated MEX-function may not be compatible with future versions of MATLAB.
-l<file>
(UNIX) Link against library lib<file>.
-L<pathname>
(UNIX) Include <pathname> in the list of directories to search for libraries.
<name>#<def>
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".
<name>=<def>
(UNIX) Override options file setting for variable <name>.
-O
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.)
-setup
Set up default options file. This switch should be the only argument passed.
-U<name>
Undefine C preprocessor macro <name>.
-v
Verbose; print all compiler and linker settings.
-V5
Compile MATLAB 5-compatible MEX-file.


  Custom Building MEX-Files Default Options File on UNIX