External Interfaces |
Step 3 -- Build the Application
Use the mex
script to compile and link engine programs. This script has a set of switches that you can use to modify the link and compile stages. The MEX Script Switches lists the available switches and their uses.
MEX Options File
MATLAB supplies an options file to facilitate building MEX applications. This file contains compiler-specific flags that correspond to the general compile, prelink, and link steps required on your system. If you want to customize the build process, you can modify this file.
Different options files are provided for UNIX and Windows.
Operating System |
Default Options File |
UNIX |
$MATLAB/bin/engopts.sh |
Windows |
$MATLAB\bin\win32\mexopts\*engmatopts.bat |
On Windows systems, the options file you use depends on which compiler you have chosen to build with. The name of each options file is prefixed with a string representing the compiler it is used with (e.g., bcc
for Borland, wat
for Watcom). Locate the options file that goes with your compiler by typing the following command:
When you start the build, use this syntax to specify which file you want MATLAB to use:
If you need to modify the options file for your particular compiler, use the mex
command with the -v
switch to view the current compiler and linker settings, and then make the appropriate changes in the options file.
Starting the Build
To build your engine application, use the mex
script and include the options filename and the name of your MEX-file.
On UNIX Systems. Use the following commands (where mexfilename
is the name of your C or Fortran program file enclosed in single quotes):
or you can copy the options file to your current working directory, and use this simpler command instead:
On Windows Systems. Use the following command (where mexfilename
is the name of your C or Fortran program file enclosed in single quotes). The command shown here is for building with the Lcc compiler. Be sure to use the .bat
file that goes with the compiler you have chosen to build with.
or you can copy the options file to your current working directory, and use this simpler command instead:
Step 2 -- Check Required Libraries and Files | Step 4 -- Set Run-time Library Path |
© 1994-2005 The MathWorks, Inc.