What are Options Files?
When you run MEX, it makes calls to the C/C++ (or FORTRAN) compiler. Each compiler needs certain flags to be set in order to do the job right. These flags are set in the options files. Each compiler has a different options file, since each compiler needs a different set of flags to be set. The options files for all supported compilers are shipped with MATLAB and you can find them in the $MATLAB/bin directory. For example, the options file for Microsoft Visual C/C++ Compiler 5.0 is msvc50opts.bat. The default options file is called mexopts.bat. When you run "mex -setup" and selsct MSVC/C++ 5.0 as your default compiler, the options file for this compiler, "msvc50opts.bat" is copied over to "mexopts.bat".
"mex -setup" also sets the paths to MATLAB and the compiler inside the options file, so that the system knows where to find MATLAB and the compiler. If any of these are not set properly, you'll get an error when you compile:
» mex yprime.c
Could not find the compiler "bcc32" on the DOS path.
Use mex -setup to configure your mex environment properly.
D:\MATLABR11\BIN\MEX.BAT: Unable to locate compiler.
»
If you run into this error, check to make sure you know where your compiler is installed and run "mex -setup" again. You can also open this file and edit it manually and put in the correct path.
Back to Table of Contents