User`s manual
1 Calling C and Fortran Programs from MATLAB
1-14
Testing Your Configuration on Windows
Before you can create MEX-files on the Windows platform, you must configure
the default options file,
mexopts.bat, for your compiler. The switch, setup,
provides an easy way for you to configure the default options file. To configure
or change the options file at anytime, run
mex -setup
from either the MATLAB or DOS command prompt.
Selecting a Compiler
MATLAB includes a C compiler, Lcc, that you can use to create C MEX-files.
The
mex script will use the Lcc compiler automatically if you do not have a C or
C++ compiler of your own already installed on your system and you try to
compile a C MEX-file. Naturally, if you need to compile Fortran programs, you
must supply your own supported Fortran compiler.
The
mex script uses the filename extension to determine the type of compiler to
use for creating your MEX-files. For example,
mex test1.f
would use your Fortran compiler and
mex test2.c
would use your C compiler.
On Systems without a Compiler. If you do not have your own C or C++ compiler on
your system, the
mex utility automatically configures itself for the included Lcc
compiler. So, to create a C MEX-file on these systems, you can simply enter
mex filename.c
This simple method of creating MEX-files works for the majority of users.
If using the included Lcc compiler satisfies your needs, you can skip ahead in
this section to “Building the MEX-File on Windows” on page 1-16.
On Systems with a Compiler. On systems where there is a C, C++, or Fortran
compiler, you can select which compiler you want to use. Once you choose your
compiler, that compiler becomes your default compiler and you no longer have