User`s manual

1 Calling C and Fortran Programs from MATLAB
1-26
For specifics on the default settings for these variables, you can:
Examine the options file in
<matlab>/bin/mexopts.sh (or the options file
you are using), or
Invoke the
mex script in verbose mode
Custom Building on Windows
There are three stages to MEX-file building for both C and Fortran on Windows
– compiling, prelinking, and linking.
Compile Stage
For the compile stage, a mex options file must:
Set up paths to the compiler using the
COMPILER (e.g., Watcom), PATH,
INCLUDE, and LIB environment variables. If your compiler always has the
environment variables set (e.g., in
AUTOEXEC.BAT), you can remark them out
in the options file.
Define the name of the compiler, using the
COMPILER environment variable,
if needed.
Define the compiler switches in the
COMPFLAGS environment variable.
a The switch to create a DLL is required for MEX-files.
b For stand-alone programs, the switch to create an exe is required.
c The -c switch (compile only; do not link) is recommended.
d The switch to specify 8-byte alignment.
e Any other switch specific to the environment can be used.
Define preprocessor
macro, with -D, MATLAB_MEX_FILE is required.
Set up optimizer switches and/or debug switches using
OPTIMFLAGS and
DEBUGFLAGS. These are mutually exclusive: the OPTIMFLAGS are the default,
Debugging
CDEBUGFLAGS FDEBUGFLAGS
LDDEBUGFLAGS
Additional libraries
CLIBS FLIBS
----
Variable C Compiler Fortran Compiler Linker