help for mex

mex -help


Usage:
  MEX [option1 ... optionN] sourcefile1 [... sourcefileN]
      [objectfile1 ... objectfileN] [libraryfile1 ... libraryfileN]

Description:
  MEX compiles and links source files into a shared library called a
  MEX-file, executable from within MATLAB. The resulting file has a
  platform-dependent extension, as shown in the table below:

    sol2, SunOS 5.x - .mexsol
    hpux            - .mexhpux
    hp700           - .mexhp7
    ibm_rs          - .mexrs6
    sgi             - .mexsg
    alpha           - .mexaxp
    glnx86          - .mexglx
    Windows         - .dll

  The first file name given (less any file name extension) will be the name
  of the resulting MEX-file. Additional source, object, or library files can
  be given to satisfy external references. On Windows, either C or Fortran,
  but not both, may be specified. On UNIX, both C and Fortran source files
  can be specified when building a MEX-file. If C and Fortran are mixed, the
  first source file given determines the entry point exported from the
  MEX-file (MATLAB loads and runs a different entry point symbol for C or
  Fortran MEX-files).

  Both an options file and command line options affect the behavior of MEX.
  The options file contains a list of variables that are passed as arguments
  to various tools such as the compiler, linker, and other platform-
  dependent tools (such as the resource linker on Windows). Command line
  options to MEX may also affect what arguments are passed to these tools,
  or may control other aspects of MEX's behavior.

Command Line Options:
  Options available on all platforms:

  -ada 
      Use this option to compile a Simulink S-function written in Ada, where
       is the Package Specification for the S-function. When this
      option is specified, only the -v (verbose) and -g (debug) options are
      relevant. All other options are ignored. See
      $MATLAB/simulink/ada/examples/README for examples and info on
      supported compilers and other requirements.
  -argcheck
      Add argument checking. This adds code so that arguments passed
      incorrectly to MATLAB API functions will cause assertion failures.
      Adds -DARGCHECK to the C compiler flags, and adds
      $MATLAB/extern/src/mwdebug.c to the list of source files. (C functions
      only).
  -c
      Compile only. Creates an object file but not a MEX-file.
  -D
      Define a symbol name to the C preprocessor. Equivalent to a
      "#define " directive in the source.
  -D#
      Define a symbol name and value to the C preprocessor. Equivalent to a
      "#define  " directive in the source.
  -f 
      Specify location and name of options file to use. Overrides MEX's
      default options file search mechanism.
  -g
      Create a debuggable MEX-file. If this option is specified, MEX appends
      the value of options file variables ending in DEBUGFLAGS with their
      corresponding base variable. (For example, the value of LINKDEBUGFLAGS
      would be appended to the LINKFLAGS variable before calling the
      linker.) This option also disables MEX's default behavior of
      optimizing built object code.
  -h[elp]
      Print this message.
  -I
      Add  to the list of directories to search for #include
      files.
  -inline
      Inline matrix accessor functions (mx*). The MEX-function generated
      may not be compatible with future versions of MATLAB.
  -n
      No execute mode. Print out any commands that MEX would otherwise have
      executed, but do not actually execute any of them.
  -O
      Optimize the object code by including the optimization flags listed in
      the options file. If this option is specified, MEX appends the value
      of options file variables ending in OPTIMFLAGS with their
      corresponding base variable. (For example, the value of LINKOPTIMFLAGS
      would be appended to the LINKFLAGS variable before calling the
      linker.) Note that optimizations are enabled by default, are disabled
      by the -g option, but are reenabled by -O.
  -outdir 
      Place all output files in directory .
  -output 
      Create MEX-file named  (an appropriate MEX-file extension
      is automatically appended). Overrides MEX's default MEX-file naming
      mechanism.
  -setup
      Interactively specify the compiler options file to use as default for
      future invocations of MEX by placing it in "\Application
      Data\MathWorks\MATLAB\R12" (for Windows) or $HOME/.matlab/R12 (for
      UNIX). When this option is specified, no other command line input is
      accepted.
  -U
      Remove any initial definition of the C preprocessor symbol .
      (Inverse of the -D option.)
  -v
      Print the values for important internal variables after the options
      file is processed and all command line arguments are considered.
      Prints each compile step and final link step fully evaluated to see
      which options and files were used. Very useful for debugging.
  -V4
      Compile a MATLAB 4-style MEX-file. This option is intended as an aid
      to migration, and is not recommended as a permanent solution.
  #
      Override an options file variable for variable . See the
      platform-dependent discussion of options files below for more details.
      This option is processed after the options file is processed and all
      command line arguments are considered.

Additional options available on Windows platforms:

  @
      Include contents of the text file  as command line arguments
      to MEX.

Additional options available on Unix platforms:

  -
      Assume local host has architecture . Possible values for 
      include sol2, hpux, hp700, alpha, ibm_rs, sgi, and glnx86.
  -D=
      Define a symbol name and value to the C preprocessor. Equivalent to a
      "#define  " directive in the source.
  -fortran
      Specify that the gateway routine is in Fortran. This will override
      what the script normally assumes, which is that the first source file
      in the list is the gateway routine.
  -l
      Link with object library "lib" (for "ld(1)").
  -L
      Add  to the list of directories containing object-library
      routines (for linking using "ld(1)").
  =
      Override an options file variable for variable . See the
      platform-dependent discussion of options files below for more details.

Options File Details:
  On Windows:
    The options file is written as a DOS batch file. If the -f option is not
    used to specify the options file name and location, then MEX searches
    for an options file named mexopts.bat in the following directories: the
    current directory, then the directory "\Application
    Data\MathWorks\MATLAB\R12". Any variable specified in the options file
    can be overridden at the command line by use of the #
    command line argument. If  has spaces in it, then it should be
    wrapped in double quotes (e.g., COMPFLAGS#"opt1 opt2"). The definition
    can rely on other variables defined in the options file; in this case
    the variable referenced should have a prepended "$" (e.g.,
    COMPFLAGS#"$COMPFLAGS opt2").

    Note: The options files in $MATLAB\bin\mexopts named *engmatopts.bat are
    special case options files that can be used with MEX (via the -f option)
    to generate stand-alone MATLAB Engine and MATLAB MAT-API executables.
    Such executables are given a ".exe" extension.

  On UNIX:
    The options file is written as a UNIX shell script. If the -f option is
    not used to specify the options file name and location, then MEX
    searches for an options file named mexopts.sh in the following
    directories: the current directory (.), then $HOME/.matlab/R12, then
    $MATLAB/bin. Any variable specified in the options file can be
    overridden at the command line by use of the = command line
    argument. If  has spaces in it, then it should be wrapped in single
    quotes (e.g., CFLAGS='opt1 opt2'). The definition can rely on other
    variables defined in the options file; in this case the variable
    referenced should have a prepended "$" (e.g., CFLAGS='$CFLAGS opt2').

    Note: The options files in $MATLAB/bin named engopts.sh and matopts.sh
    are special case options files that can be used with MEX (via the -f
    option) to generate stand-alone MATLAB Engine and MATLAB MAT-API
    executables. Such executables are not given any default extension.

Examples:
    The following command will compile "myprog.c" into "myprog.mexsol" (when
    run under Solaris):

      mex myprog.c

    When debugging, it is often useful to use "verbose" mode as well
    as include symbolic debugging information:

      mex -v -g myprog.c