mcc
Compile MATLAB functions for deployment
Syntax
Description
You can use mcc
to package and deploy MATLAB® programs as standalone applications, Excel® add-ins, Spark™ applications, or Hadoop® jobs.
If you have a MATLAB
Compiler SDK™ license, you can use mcc
to create C/C++ shared libraries,
.NET assemblies, Java® packages, Python® packages, MATLAB
Production Server™ deployable archives, or Excel add-ins for MATLAB
Production Server.
General Usage
mcc [options]
compiles the functions as specified by the options. The options used depend on the
intended results of the compilation. The first file acts as the entry point to the
compiled artifact.mfilename1 mfilename2 ... mfilenameN
You can also call this syntax from a system command prompt.
Note
Arguments that contain special characters (such as period or space) must be surrounded by single quotes. Use double quotes when executing from a Windows® command prompt.
mcc(options,
compiles the function as specified by the options. Specify file names and options as
character vectors or strings. This syntax allows you to use MATLAB variables as input arguments.mfilename
)
Standalone Application
mcc -m [options]
compiles the function into a standalone application. The executable type is determined by
your operating system.mfilename
As an alternative, the compiler.build.standaloneApplication
function supports most common
workflows.
mcc -e [options]
compiles the
function into a standalone application that does not open a Windows command prompt on execution. The mfilename
-e
option works only on
Windows operating systems.
As an alternative, the compiler.build.standaloneWindowsApplication
function supports most common
workflows.
Excel Add-In
mcc -W 'excel:
creates a Microsoft®
Excel add-in using the specified files. Before creating Excel add-ins, install a supported compiler.addin_name
,class_name
,version=version_number
'
[options] mfilename1 mfilename2 ... mfilenameN
You can only create Excel add-ins on Windows.
addin_name
— Specifies the name of the add-in. If you do not specify the name,mcc
uses
as the default.mfilename1
class_name
— Specifies the name of the class to be created. If you do not specify the class name,mcc
usesaddin_name
as the class name. If specified,class_name
must be different from
.mfilename1
version_number
— Specifies the version number of the add-in file asmajor.minor.bug.build
in the file system. You are not required to specify a version number. If you do not specify a version number,mcc
sets the version number to1.0.0.0
by default.major
— Specifies the major version number. If you do not specify a number,mcc
setsmajor
to1
.minor
— Specifies the minor version number. If you do not specify a number,mcc
setsminor
to0
.bug
— Specifies the bug fix maintenance release number. If you do not specify a number,mcc
setsbug
to0
.build
— Specifies the build number. If you do not specify a number,mcc
setsbuild
to0
.
As an alternative, the compiler.build.excelAddIn
function supports most common workflows.
MapReduce Applications on Hadoop
Linux® only
mcc -W 'hadoop:
generates a deployable archive from archive_name
,CONFIG:config_file
' mfilename
mfilename
that can be run as a
job by Hadoop.
archive_name
— Specifies the name of the generated archive.config_file
— Specifies the path to the configuration file for creating a deployable archive. For more information, see Configuration File for Creating Deployable Archive Using the mcc Command.
Simulink Simulations
Requires Simulink® Compiler™
mcc -m [options]
compiles a MATLAB application that contains a Simulink simulation into a standalone application. For more information,
see Create and Deploy a Script with Simulink Compiler (Simulink Compiler).mfilename
Python Package
Requires MATLAB Compiler SDK
mcc -W python:
creates a Python package using the specified files.package_name
[options] mfilename1 mfilename2 ... mfilenameN
package_name
— Specifies the name of the Python package preceded by an optional namespace, which is a period-separated list such ascompanyname.groupname.component
.
As an alternative, the compiler.build.pythonPackage
(MATLAB Compiler SDK) function supports most common workflows.
.NET Assembly
Requires MATLAB Compiler SDK
mcc -W 'dotnet:
creates a .NET assembly with a single class using the specified files. Before creating
.NET assemblies, see MATLAB Compiler SDK .NET Target Requirements (MATLAB Compiler SDK).assembly_name
,api=api_type
,class_name
,framework_version
,security
,remote_type
' [options] mfilename1 mfilename2 ... mfilenameN
assembly_name
— Specifies the name of the assembly preceded by an optional namespace, which is a period-separated list such ascompanyname.groupname.component
.api_type
— Specifies the API type of the assembly. Values arematlab-data
andmwarray
. The default value ismwarray
.class_name
— Specifies the name of the .NET class to be created.framework_version
— Specifies the version of the Microsoft .NET Framework you want to use to compile the assembly. Specify either:0.0
— Use the latest supported version on the target machine.
— Use a specific version of the framework.version_major
.version_minor
Features are often version-specific. Consult the documentation for the feature you are implementing to get the Microsoft .NET Framework version requirements.
security
— Specifies whether the assembly to be created is a private assembly or a shared assembly.To create a private assembly, specify
Private
.To create a shared assembly, specify the full path to the encryption key file used to sign the assembly.
remote_type
— Specifies the remoting type of the assembly. Values areremote
andlocal
.
mcc -W 'dotnet:
creates a .NET assembly with multiple classes using the specified files. You can include
additional class specifiers by adding assembly_name
,api=api_type
,class_name
,framework_version
,security
,remote_type
' [options] 'class{class_name:mfilename1,mfilename2,...,mfilenameN}
'class{___}
arguments.
As an alternative, the compiler.build.dotNETAssembly
(MATLAB Compiler SDK) function supports most common
workflows.
Java Package
Requires MATLAB Compiler SDK
mcc -W 'java:
creates a Java package from the specified files. Before creating Java packages, see Configure Your Java Environment (MATLAB Compiler SDK).package_name
,class_name
' [options] mfilename1 mfilename2 ... mfilenameN
package_name
— Specifies the name of the Java package preceded by an optional namespace, which is a period-separated list such ascompanyname.groupname.component
.class_name
— Specifies the name of the class to be created. If you do not specify the class name,mcc
uses the last item inpackage_name
.
mcc -W 'java:
creates a Java package with multiple classes from the specified files. You can include
additional class specifiers by adding package_name
,class_name
' [options] 'class{class_name:mfilename1,mfilename2,...,mfilenameN}
'class{___}
arguments.
As an alternative, the compiler.build.javaPackage
(MATLAB Compiler SDK) function supports most common workflows.
C Shared Library
Requires MATLAB Compiler SDK
mcc -l [options]
compiles the listed functions into a C shared library and generates C wrapper
code for integration with other applications.mfilename1 mfilename2 ... mfilenameN
As an alternative, the compiler.build.cSharedLibrary
(MATLAB Compiler SDK) function supports most common
workflows.
C++ Shared Library
Requires MATLAB Compiler SDK
mcc -W 'cpplib:
compiles the listed functions into a C++ shared library and generates C++ wrapper code for
integration with other applications.library_name
[,{all|legacy|generic}]' [options] mfilename1 mfilename2 ... mfilenameN
library_name
— Specifies the name of the shared library.all
— Generates shared libraries using both themwArray
API and the generic interface that uses the MATLAB Data API. This is the default behavior.legacy
— Generates shared libraries using themwArray
API.generic
— Generates shared libraries using the MATLAB Data API.
As an alternative, the compiler.build.cppSharedLibrary
(MATLAB Compiler SDK) function supports most common
workflows.
COM Component
Requires MATLAB Compiler SDK
mcc -W 'com:
compiles the listed functions into a generic Microsoft COM component.component_name
,class_name
' [options] mfilename1 mfilename2 ... mfilenameN
component_name
— Specifies the name of the COM component.
class_name
— Specifies the name of the class.
As an alternative, the compiler.build.comComponent
(MATLAB Compiler SDK) function supports most common
workflows.
mcc -W 'com:component_name,
creates a Microsoft COM component with multiple classes from the specified files. You can
include additional class specifiers by adding class_name
' [options] 'class{class_name:mfilename1,mfilename2,...,mfilenameN}
'class{___}
arguments.
Deployable Archive for MATLAB Production Server
Requires MATLAB Compiler SDK
mcc -U -W 'CTF:
creates a deployable archive (archive_name
[,DISCOVERY:FunctionSignatures.json
][,ROUTES:ArchiveRoutes.json
]' [options] mfilename1 mfilename2 ... mfilenameN
.ctf
file) for use with a MATLAB
Production Server instance.
archive_name
— Specifies the name of the deployable archive.FunctionSignatures.json
— Specifies the JSON file that contains information about your MATLAB functions, specified as an absolute or relative path. This options is relevant only for RESTful clients using the discovery API. For more information, see MATLAB Function Signatures in JSON (MATLAB Production Server).ArchiveRoutes.json
— Specifies the JSON file that contains URL routes for mapping client requests to MATLAB web handler functions within the archive. Use this option to organize routes by deployable archive name instead of defining them all in the server-level routes file specified by theroutes-file
(MATLAB Production Server) server configuration property. For more information on web request handlers, see Handle Custom Routes and Payloads in HTTP Requests (MATLAB Production Server).
The syntax also creates a server-side deployable archive
(.ctf
file) for Microsoft
Excel add-ins.
As an alternative, the compiler.build.productionServerArchive
(MATLAB Compiler SDK) function supports most common
workflows, but it does not support creating archive-specific routes.
Excel Add-In for MATLAB Production Server
Requires MATLAB Compiler SDK
mcc -W 'mpsxl:
creates a client-side Microsoft
Excel add-in from the specified files that can be used to send requests to
MATLAB
Production Server from Excel. Creating the client-side add-in must be preceded by
creating a server-side deployable archive (addin_name
,class_name
,version
' input_marshaling_flags
output_marshaling_flags
[options] mfilename1 mfilename2 ... mfilenameN
.ctf
file) from the
specified files. A purely client side add-in is not viable.
addin_name
— Specifies the name of the add-in.class_name
— Specifies the name of the class to be created. If you do not specify the class name,mcc
uses theaddin_name
as the default.version
— Specifies the version of the add-in specified asmajor
.minor
.major
— Specifies the major version number. If you do not specify a version number,mcc
uses the latest version.minor
— Specifies the minor version number. If you do not specify a version number,mcc
uses the latest version.
input_marshaling_flags
— Specifies options for how data is marshaled between Microsoft Excel and MATLAB.-replaceBlankWithNaN
— Specifies that a blank in Microsoft Excel is marshaled into NaN in MATLAB. If you do not specify this flag, blanks are marshaled into 0.-convertDateToString
— Specifies that dates in Microsoft Excel are marshaled into MATLAB character vectors. If you do not specify this flag, dates are marshaled into MATLAB doubles.
output_marshaling_flags
— Specifies options for how data is marshaled between MATLAB and Microsoft Excel.-replaceNaNWithZero
— Specifies that NaN in MATLAB is marshaled into a 0 in Microsoft Excel. If you do not specify this flag, NaN is marshalled into#QNAN
in Visual Basic®.-convertNumericToDate
— Specifies that MATLAB numeric values are marshaled into Microsoft Excel dates. If you do not specify this flag, Microsoft Excel does not receive dates as output.
As an alternative, the compiler.build.excelClientForProductionServer
(MATLAB Compiler SDK) function supports
most common workflows.
Examples
Input Arguments
Limitations
mcc
cannot create web apps. To create web apps, use the Web App Compiler app or thecompiler.build.webAppArchive
function.You can use
mcc
to build components on MATLAB Online Server™, which acts as a Linux environment (since R2022b). To build targets that require an external compiler, including JavaJava, C++, and COM components, the MATLAB Online Server worker must be set up to run the required toolchain.
Tips
On Windows, you can generate a system-level file version number for your target file by appending
version=
version_number
to the target generatingmcc
syntax. For an example, see Create Excel Add-In (Windows only).version_number
— Specifies the version of the target file asmajor.minor.bug.build
in the file system. You are not required to specify a version number. If you do not specify a version number,mcc
sets the version number, by default, to1.0.0.0
.major
— Specifies the major version number. If you do not specify a version number,mcc
setsmajor
to1
.minor
— Specifies the minor version number. If you do not specify a version number,mcc
setsminor
to0
.bug
— Specifies the bug fix maintenance release number. If you do not specify a version number,mcc
setsbug
to0
.build
— Specifies build number. If you do not specify a version number,mcc
setsbuild
to0
.
This functionality is supported for standalone applications and Excel add-ins in MATLAB Compiler.
This functionality is supported for C shared libraries, C++ shared libraries, COM components, .NET assemblies, and Excel add-ins for MATLAB Production Server in MATLAB Compiler SDK.
Version History
Introduced before R2006a