User`s manual
Custom Building MEX-Files
1-27
and the DEBUGFLAGS are used if you set the -g switch on the mex command
line.
Prelink Stage
The prelink stage dynamically creates import libraries to import the required
function into the MEX, MAT, or engine file. All MEX-files link against
MATLAB only. MAT stand-alone programs link against
libmx.dll (array
access library) and
libmat.dll (MAT-functions). Engine stand-alone programs
link against
libmx.dll (array access library) and libeng.dll for engine
functions. MATLAB and each DLL have corresponding
.def files of the same
names located in the <
matlab>\extern\include directory.
Link Stage
Finally, for the link stage, a mex options file must:
•Define the name of the linker in the
LINKER environment variable.
•Define the
LINKFLAGS environment variable that must contain:
- The switch to create a DLL for MEX-files, or the switch to create an
exe
for stand-alone programs.
- Export of the entry point to the MEX-file as
mexFunction for C or
MEXFUNCTION@16 for DIGITAL Visual Fortran.
- The import library(s) created in the
PRELINK_CMDS stage.
- Any other link switch specific to the compiler that can be used.
•Define the linking optimization switches and debugging switches in
LINKEROPTIMFLAGS and LINKDEBUGFLAGS. As in the compile stage, these two
are mutually exclusive: the default is optimization, and the
-g switch
invokes the debug switches.
•Define the link-file identifier in the
LINK_FILE environment variable, if
needed. For example, Watcom uses
file to identify that the name following
is a file and not a command.
•Define the link-library identifier in the
LINK_LIB environment variable, if
needed. For example, Watcom uses
library to identify the name following is
a library and not a command.
•Optionally, set up an output identifier and name with the output switch in
the
NAME_OUTPUT environment variable. The environment variable MEX_NAME
contains the name of the first program in the command line. This must be set