compiler.runtime.customInstaller - Create a MATLAB Runtime installer for the specified files generated by MATLAB
Compiler - MATLAB ([original](https://www.mathworks.com/help/compiler/compiler.runtime.custominstaller.html)) ([raw](?raw))
Create a MATLAB Runtime installer for the specified files generated by MATLAB Compiler
Since R2024b
Syntax
Description
compiler.runtime.customInstaller([installerName](#mw%5F15ed4e9f-c65d-444a-807b-696aafd0b0ee), [results](#mw%5F1116eb65-e67a-44ab-a389-96cd069e40b6))
creates a MATLAB® Runtime installer with a minimal size footprint that installs only the MATLAB Runtime components required to run the specified artifacts created with MATLAB Compiler™ or MATLAB Compiler SDK™. You specify the artifacts using results
, which is a vector of one or more compiler.build.Results
objects created by anycompiler.build
function.
compiler.runtime.customInstaller([installerName](#mw%5F15ed4e9f-c65d-444a-807b-696aafd0b0ee), [filepath](#mw%5Ffc29e0eb-dee8-4c8a-a1b8-719c4593abbc))
creates a MATLAB Runtime installer using a list of requiredMCRProducts.txt
files generated by MATLAB Compiler.
compiler.runtime.customInstaller(___,[Name=Value](#namevaluepairarguments))
creates a MATLAB Runtime installer with additional options specified as one or more name-value arguments. Options include the output folder, package type, and runtime delivery method.
Examples
Create a minimal MATLAB Runtime installer that installs all MATLAB Runtime components required to run a standalone application.
Write a MATLAB function to package into a standalone application. For this example, compile using the filemagicsquare.m
.
copyfile(fullfile(matlabroot,"extern","examples","compiler","magicsquare.m"));
Create a standalone application usingcompiler.build.standaloneApplication
. Save the output from the function as a compiler.build.Results
object.
results = compiler.build.standaloneApplication("magicsquare.m");
Create a MATLAB Runtime installer that contains the components required to run the standalone application.
compiler.runtime.customInstaller("magicsquareInstaller",results);
Deploy the standalone application and generated MATLAB Runtime installer on the target machine.
The installed MATLAB Runtime takes up less space than a full MATLAB Runtime installation.
Create a minimal MATLAB Runtime installer on an offline machine by using the full MATLAB Runtime installer.
Using a machine connected to the internet, download the full MATLAB Runtime installer for the offline machine's MATLAB release. For details, see Download and Install MATLAB Runtime (MATLAB Compiler SDK). Transfer the installer to the offline machine.
On the offline machine, in MATLAB, open the Preferences menu and selectMATLAB Compiler. Specify the location of the MATLAB Runtime installer.
On the offline machine, write a MATLAB function to package into a standalone application. For this example, compile using the filemagicsquare.m
.
copyfile(fullfile(matlabroot,"extern","examples","compiler","magicsquare.m"));
Create a standalone application usingcompiler.build.standaloneApplication
. Save the output from the function as a compiler.build.Results
object.
results = compiler.build.standaloneApplication("magicsquare.m");
Create a MATLAB Runtime installer that contains the components required to run the standalone application.
compiler.runtime.customInstaller("magicsquareInstaller",results);
Deploy the standalone application and generated MATLAB Runtime installer on the target machine.
Create a MATLAB Runtime installer on Windows® using the requiredMCRProducts.txt
files generated byMATLAB Compiler.
Write a MATLAB function to package into a standalone Windows application. For this example, copy the MATLAB script flames.m
and data fileflames.mat
to your current working directory.
copyfile(fullfile(matlabroot,"extern","examples","compiler","flames.*"));
Use mcc
to create a standalone Windows application using flames.m
.
mcc("flames.m","-e","-a","flames.mat","-d","flames")
Create an Excel® add-in using the file houdini.m
.
copyfile(fullfile(matlabroot,"extern","examples","compiler","houdini.m")); compiler.build.excelAddIn("houdini.m","GenerateVisualBasicFile","on","OutputDir","houdini");
Create a MATLAB Runtime installer that contains the components required to run both the standalone application and the Excel add-in.
compiler.runtime.customInstaller("flames_houdiniInstaller",... ["flames\requiredMCRProducts.txt","houdini\requiredMCRProducts.txt"]);
A MATLAB Runtime installer named flames_houdiniInstaller.exe
is generated in the folder flames_houdiniInstaller
.
Create a MATLAB Runtime installer that installs all MATLAB Runtime components required to run multiple C++ shared libraries.
For this example, copy the matrix folder that ships with MATLAB to your work folder.
copyfile(fullfile(matlabroot,"extern","examples","compilersdk","c_cpp","matrix"),"matrix")
Navigate to the new matrix
subfolder in your work folder.
Create two C++ shared libraries usingcompiler.build.cppSharedLibrary
.
functionfiles = {"addmatrix.m", "multiplymatrix.m", "eigmatrix.m"};
results1 = compiler.build.cppSharedLibrary(functionfiles,... "OutputDir","matrixLibraries");
results2 = compiler.build.cppSharedLibrary("subtractmatrix.m",... "OutputDir","matrixLibraries");
Create a MATLAB Runtime installer that can be used for all libraries. Use name-value arguments to specify the build folder and embed MATLAB Runtime in the installer for offline deployment.
compiler.runtime.customInstaller("matrixInstaller",[results1,results2],... OutputDir="customInstallers",RuntimeDelivery="installer")
The installer matrixInstaller.zip
is generated in thecustomInstallers
folder in the current working directory.
Deploy the MATLAB Runtime installer and shared library files (.ctf
and.hpp
) to the target machine.
Input Arguments
Name of the installer file, specified as a character vector or a string scalar. The extension is determined by the operating system in which the function is executed.
Example: "MagicSquare_Installer"
One or more paths to requiredMCRProducts.txt
, which is generated by MATLAB Compiler or MATLAB Compiler SDK.
Example: ["fun1/requiredMCRProducts.txt","fun2/requiredMCRProducts.txt"]
Name-Value Arguments
Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN
, where Name
is the argument name and Value
is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.
Example: PackageType="zip"
Since R2025a
Optional MATLAB Runtime dependencies to include in the installer, specified as one of the following:
"all"
— Option to include all of the optional dependencies in the installer, including graphical support. This option is the default behavior."none"
— Option to not include any of the optional dependencies in the installer. Use this option to minimize the size of the generated installer.
Example: OptionalDependencies="none"
Path to the output directory where the installer is saved, specified as a character vector or a string scalar. The path can be relative to the current working directory or absolute.
The default name of the output folder is the value ofinstallerName.
Example: OutputDir="D:\Documents\MATLAB\work\myappInstaller"
Data Types: char
| string
Installer file type, specified as one of the following options.
"auto"
—Option for installer to automatically select the suitable file type when creating the installer. If the installer size is 2GB or greater, the installer is packaged as a ZIP file. This is the default option."zip"
—Option to always generate a ZIP file as an output when creating a new installer. This option is only supported whenRuntimeDelivery
is set to"installer"
. This option is only supported on Windows systems.
Example: PackageType="zip"
Data Types: char
| string
MATLAB Runtime delivery method, specified as one of the following options.
"web"
—Option for installer to download MATLAB Runtime from the MathWorks® website during application installation. This is the default option."installer"
—Option to include MATLAB within the installer so that it can be installed during application installation without connecting to the MathWorks website. Use this option if you think your end user may not have access to the Internet.
Example: RuntimeDelivery="installer"
Data Types: char
| string
Tips
- The installer created by this function installs a subset of MATLAB Runtime components with a minimal size footprint. To download the full MATLAB Runtime installer, see compiler.runtime.download.
- If you use multiple installers created by this function, MATLAB Runtime is updated to contain the minimal subset of components across all of the installers. This means that you can run multiple MATLAB Compiler generated artifacts with the same instance of MATLAB Runtime by using custom installers created from each build.
- The installer created by this function does not install your MATLAB Compiler generated artifacts. To create an installer for packaged MATLAB code, see compiler.package.installer.
Version History
Introduced in R2024b
You can use the OptionalDependencies
option to control whether to include all of the optional MATLAB Runtime dependencies in the installer.