User`s manual
1 Calling C and Fortran Programs from MATLAB
1-20
Custom Building MEX-Files
This section discusses in detail the process that the MEX-file build script uses.
It covers the following topics:
•“Who Should Read This Chapter”
•“MEX Script Switches”
•“Default Options File on UNIX”
•“Default Options File on Windows”
•“Custom Building on UNIX”
•“Custom Building on Windows”
Who Should Read This Chapter
In general, the defaults that come with MATLAB should be sufficient for
building most MEX-files. There are reasons that you might need more detailed
information, such as:
•You want to use an Integrated Development Environment (IDE), rather than
the provided script, to build MEX-files.
•You want to create a new options file, for example, to use a compiler that is
not directly supported.
•You want to exercise more control over the build process than the script uses.
The script, in general, uses two stages (or three, for Microsoft Windows) to
build MEX-files. These are the compile stage and the link stage. In between
these two stages, Windows compilers must perform some additional steps to
prepare for linking (the prelink stage).
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