MATLAB Compiler | ![]() ![]() |
Creating Stand-Alone Applications
C Stand-Alone Applications
The MATLAB Compiler, when invoked with the -m
macro option, translates input M-files into C source code that is usable in any of the supported executable types. The Compiler also produces the required wrapper file suitable for a stand-alone application. Then, your ANSI C compiler compiles these C source code files and the resulting object files are linked against the MATLAB C/C++ Math and Graphics Libraries, which are included with the MATLAB Compiler. For more information about distributing a C application, see Distributing Stand-Alone Applications.
C++ Stand-Alone Applications
The MATLAB Compiler, when invoked with the -p
macro option, translates input M-files into C++ source code that is usable in any of the executable types except MEX. The Compiler also produces the required wrapper file suitable for a stand-alone application. Then, your C++ compiler compiles this C++ source code and the resulting object files are linked against the MATLAB C/C++ Math and Graphics Libraries, which are included with the MATLAB Compiler. For more information about which libraries must be included when you distribute a C++ application, see Distributing Stand-Alone Applications.
Developing a Stand-Alone Application
Suppose you want to create an application that calculates the rank of a large magic square. One way to create this application is to code the whole application in C or C++; however, this would require writing your own magic square, rank, and singular value routines.
An easier way to create this application is to write it as one or more M-files. Figure 1-2, Developing a Typical Stand-Alone C Application, outlines this development process.
Figure 1-2: Developing a Typical Stand-Alone C Application
See Stand-Alone Applications for complete details regarding stand-alone applications.
Figure 1-2, Developing a Typical Stand-Alone C Application, illustrates the process of developing a typical stand-alone C application. Use the same basic process for developing stand-alone C++ applications, but use the -p
option instead of the -m
option with the MATLAB Compiler and a C++ compiler instead of a C compiler.
Note
The MATLAB Compiler contains a tool, mbuild , which simplifies much of this process. Stand-Alone Applications describes the mbuild tool.
|
-p
and -m
are examples of options that you use to control how the Compiler works. Chapter 7, "Reference," includes a complete description of the Compiler options in the mcc
section. Throughout this book you will see numerous examples of how these options are used with the Compiler to perform various tasks.
![]() | Creating MEX-Files | The MATLAB Compiler Family | ![]() |