mcc
Compile MATLAB functions for deployment
Syntax
Description
Other mcc
Topics
This topic describes mcc
options for use
with MATLAB®
Compiler SDK™. For information on compiling:
General Usage
mcc
compiles the functions as specified by the options. The options used depend on
the intended results of the compilation.options
mfilename1 mfilename2 ... mfilenameN
mcc('
compiles the function as specified by the options. Specify filenames, options,
and option parameters in single quotes.options
','mfilename
')
C Shared Library
mcc -l
compiles the listed functions into a C shared library and generates C wrapper
code for integration with other applications.options
mfilename1 mfilename2 ... mfilenameN
This syntax is equivalent to -W
lib:
.libname
-T link:lib
C++ Shared Library
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.legacy
— Generates shared libraries using themwArray
API.generic
— Generates shared libraries using the MATLAB Data API.
COM Component
mcc -W com:
compiles the listed functions into a generic Microsoft® COM component.component_name
,className
options
class{className:mfilename1,mfilename2,...,mfilenameN}
Note
File names listed in the class{___}
argument must
be separated by commas.
You can include multiple class specifiers by adding additional
class{
___}
arguments.
component_name
— Specifies the name of the COM component.
className
— Specifies the name of the class.
.NET Assembly
mcc -W dotnet:
creates a .NET assembly with a single class from the specified files.assembly_name
,api=api_type
,className
,framework_version
,security
,remote_type
-T
link:lib 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
.className
— 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 from the specified files.assembly_name
,api=api_type
,className
,framework_version
,security
,remote_type
-T
link:lib options
class{className:mfilename1,mfilename2,...,mfilenameN}
Note
File names listed in the class{___}
argument must
be separated by commas.
You can include multiple class specifiers by adding additional
class{___}
arguments.
Java Package
mcc -W java:
creates a Java® package from the specified files.packageName
,className
options
mfilename1 mfilename2 ... mfilenameN
packageName
— Specifies the name of the Java package preceded by an optional namespace, which is a period-separated list, such ascompanyname.groupname.component
.className
— Specifies the name of the class to be created. If you do not specify the class name,mcc
uses the last item inpackageName
.
mcc -W java:
creates a Java package with multiple classes from the specified files.packageName
,className
options
class{className:mfilename1,mfilename2,...,mfilenameN}
Note
File names listed in the class{___}
argument must
be separated by commas.
packageName
— Specifies the name of the Java package preceded by an optional namespace, which is a period-separated list, such ascompanyname.groupname.component
.className
— Specifies the name of the class to be created. If you do not specify the class name,mcc
uses the last item inpackageName
.Note
You can include multiple class specifiers by adding additional
class{___}
arguments.
Python Package
mcc -W python:
creates a Python® package from the specified files.packageName
-T
link:lib options
mfilename1 mfilename2 ... mfilenameN
packageName
— Specifies the name of the Python package preceded by an optional namespace, which is a period-separated list, such ascompanyname.groupname.component
.
Deployable Archive for MATLAB Production Server
mcc -W CTF:
instructs the compiler to create a deployable archive (archive_name
-U options
mfilename1 mfilename2 ... mfilenameN
.ctf
file) for use with a MATLAB
Production Server instance.
The syntax also creates the server-side deployable archive
(.ctf
file) for Microsoft
Excel add-ins.
Excel Add-In for MATLAB Production Server
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
,className
,version
input_marshaling_flags
output_marshaling_flags
-T
link:lib 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.className
— 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 mashaled 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.
Examples
Create a standalone application and include MATLAB preferences
mcc -m helloWorld.m -a C:\Users\someuser\AppData\Roaming\MathWorks\MATLAB\R2022b\matlab.mlsettings
Create a C shared library
mcc -l mymagic.m
Create a C shared library with a system-level file version number (Windows only)
Create a C shared library in Windows® with version number 4.3.1.7
.
mcc -W 'lib:myCSharedLib,version=4.3.1.7' mymagic.m
Create a C++ shared library
Use the mwArray
API
mcc -W 'cpplib:mymagic,legacy' mymagic.m
Use the MATLAB Data API
mcc -W 'cpplib:mymagic,generic' mymagic.m
Use both the mwArray
API and the MATLAB Data
API
mcc -W 'cpplib:mymagic,all' mymagic.m
mcc -W 'cpplib:mymagic' mymagic.m
Create a C++ shared library with a system-level file version number (Windows only)
Create a C++ shared library in Windows with version number 3.7.1.5
.
mcc -W 'cpplib:mymagic,all,version=3.7.1.5' mymagic.m
Create a COM component
Create a COM component in Windows with version number 7.10.1.3
.
mcc -W 'com:myCOMComponent,myClass,version=7.10.1.3' class{myClass:mymagic.m}
Create a Java package containing multiple classes
mcc -W 'java:myMatrix,add' class{add:add.m} class{sub:minus.m}
Create a Python package
mcc -W python:myMagic magic.m
Create a deployable archive for MATLAB Production Server
mcc -W CTF:myDeployableArchive -U mymagic.m
Create an Excel add-in for MATLAB Production Server
mcc -W 'mpsxl:myDeployableArchive,myExcelClass,version=1.0' mymagic.m
Input Arguments
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 a C++ shared library with a system-level file version number (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 C shared libraries, C++ shared libraries, COM components, .NET assemblies, and Excel add-ins for MATLAB Production Server in MATLAB Compiler SDK. For supported targets in MATLAB Compiler, see the Tips section in
mcc
.
Version History
Introduced before R2006a