User`s manual

1 Calling C and Fortran Programs from MATLAB
1-28
for -output to work. If this environment is not set, the compiler default is to
use the name of the first program in the command line. Even if this is set, it
can be overridden by specifying the
mex -output switch.
Linking DLLs to MEX-Files
To link a DLL to a MEX-file, list the DLL’s .lib file on the command line.
Versioning MEX-Files
The mex script can build your MEX-file with a resource file that contains
versioning and other essential information. The resource file is called
mexversion.rc and resides in the extern\include directory. To support
versioning, there are two new commands in the options files,
RC_COMPILER and
RC_LINKER, to provide the resource compiler and linker commands. It is
assumed that:
If a compiler command is given, the compiled resource will be linked into the
MEX-file using the standard link command.
If a linker command is given, the resource file will be linked to the MEX-file
after it is built using that command.
Compiling MEX-Files with the Microsoft Visual C++ IDE
Note This section provides information on how to compile MEX-files in the
Microsoft Visual C++ (MSVC) IDE; it is not totally inclusive. This section
assumes that you know how to use the IDE. If you need more information on
using the MSVC IDE, refer to the corresponding Microsoft documentation.
To build MEX-files with the Microsoft Visual C++ integrated development
environment:
1 Create a project and insert your MEX source and mexversion.rc into it.
2 Create a .DEF file to export the MEX entry point. For example
LIBRARY MYFILE.DLL
EXPORTS mexFunction
<-- for a C MEX-file
or
EXPORTS MEXFUNCTION@16 <-- for a Fortran MEX-file