compiler.package.installer
Create an installer for files generated by MATLAB Compiler
Syntax
Description
compiler.package.installer( creates an
installer using the results)compiler.build.Results object results generated from a
compiler.build function.
compiler.package.installer(
creates an installer using the results,Name,Value)compiler.build.Results object
results with additional options specified using one or more
name-value arguments.
compiler.package.installer(
creates an installer for files generated by the files,filePath,"ApplicationName",appName,Name,Value)mcc command. The
installed application name is specified by appName. The installer can
be customized using optional name-value arguments.
Examples
Create an installer for a standalone application using the results
from the compiler.build.standaloneApplication function.
In MATLAB®, locate the MATLAB code that you want to deploy as a standalone application. For this
example, compile using the file magicsquare.m located in
.matlabroot\extern\examples\compiler
appFile = fullfile(matlabroot,"extern","examples","compiler","magicsquare.m");
Build a standalone application using the
compiler.build.standaloneApplication command.
results = compiler.build.standaloneApplication(appFile);
Create an installer for the standalone application using the
compiler.package.installer
function.
compiler.package.installer(results);
MyAppInstaller within a folder
named magicsquareinstaller.The default installation folder for the application is the value of the
%ProgramFiles% environment variable on the target machine.
Create an installer for a standalone application using the results
from the compiler.build.standaloneApplication function on an offline machine.
On the offline machine, use the compiler.runtime.download function to obtain the URL to the MATLAB Runtime installer at the matching version and update
level.
compiler.runtime.download
Downloading MATLAB Runtime installer. It may take several minutes... Error using compiler.runtime.download A connection could not be established to download the Runtime Installer. Download the runtime from: https://ssd.mathworks.com/supportfiles/downloads/R2025b/Release/0/deployment_files/installer/complete/win64/MATLAB_Runtime_R2025b_win64.zip and update the runtime location in Compiler Settings.
Using a machine that is connected to the Internet, download the installer using the URL provided and transfer the installer to the offline machine.
On the offline machine, in MATLAB, open the Settings menu and select MATLAB Compiler. Specify the location of the MATLAB Runtime installer.
On the offline machine, locate the MATLAB code that you want to deploy as a standalone application. For this
example, compile using the file magicsquare.m located in
.matlabroot\extern\examples\compiler
copyfile(fullfile(matlabroot,"extern","examples","compiler","magicsquare.m"));
Build a standalone application using the
compiler.build.standaloneApplication command.
results = compiler.build.standaloneApplication("magicsquare.m");Create an installer for the standalone application using the
compiler.package.installer
function.
compiler.package.installer(results);
MyAppInstaller within a folder
named magicsquareinstaller.The default installation folder for the application is the value of the
%ProgramFiles% environment variable on the target machine.
Create an installer for a standalone application using the results
from the compiler.build.standaloneApplication function and customize it using
name-value arguments.
Copy the file magicsquare.m located in
.matlabroot\extern\examples\compiler
copyfile(fullfile(matlabroot,"extern","examples","compiler","magicsquare.m"));
Build a standalone application using the
compiler.build.standaloneApplication command.
results = compiler.build.standaloneApplication("magicsquare.m");Create an installer for the standalone application using the
compiler.package.installer function using the
Results object. Use name-value arguments to specify the installer
name and include MATLAB Runtime within the
installer.
compiler.package.installer(results,... "InstallerName","MyMagicInstaller",... "RuntimeDelivery","installer");
MyMagicInstaller within a folder named
magicsquareinstaller.Create an installer for a standalone application on a Windows® system using the results from the compiler.build.standaloneApplication function. Customize the installer using
an InstallerOptions object.
Copy the file magicsquare.m located in
.matlabroot\extern\examples\compiler
copyfile(fullfile(matlabroot,"extern","examples","compiler","magicsquare.m"));
Build a standalone application using the
compiler.build.standaloneApplication command.
results = compiler.build.standaloneApplication("magicsquare.m"); Create an InstallerOptions object. Use name-value arguments to
specify the application name, author company, author name, installer name, and
summary.
opts = compiler.package.InstallerOptions(results,... "ApplicationName","MagicSquare_Generator",... "AuthorCompany","Boston Common",... "AuthorName","Frog",... "InstallerName","MagicSquare_Installer",... "Summary","Generates a magic square.")
opts =
InstallerOptions with properties:
RuntimeDelivery: 'web'
InstallerSplash: 'C:\Program Files\MATLAB\R2025b\toolbox\compiler\packagingResources\default_splash.png'
InstallerIcon: 'C:\Program Files\MATLAB\R2025b\toolbox\compiler\packagingResources\default_icon_48.png'
InstallerLogo: 'C:\Program Files\MATLAB\R2025b\toolbox\compiler\packagingResources\default_logo.png'
PackageType: 'auto'
AdditionalFiles: {}
AddRemoveProgramsIcon: 'C:\Program Files\MATLAB\R2025b\toolbox\compiler\packagingResources\default_icon_48.png'
AuthorName: 'Frog'
AuthorEmail: ''
AuthorCompany: 'Boston Common'
Summary: 'Generates a magic square.'
Description: ''
InstallationNotes: ''
OptionalDependencies: 'all'
Shortcut: 'D:\Work\magicsquarestandaloneApplication\magicsquare.exe'
Verbose: 'off'
Version: '1.0'
InstallerName: 'MagicSquare_Installer'
ApplicationName: 'MagicSquare_Generator'
OutputDir: '.\MagicSquare_Generatorinstaller'
DefaultInstallationDir: '%ProgramFiles%\MagicSquare_Generator'Create an installer for the standalone application using the
Results and InstallerOptions objects as inputs to
the compiler.package.installer function.
compiler.package.installer(results,"Options",opts);MagicSquare_Installer within a
folder named MagicSquare_Generatorinstaller.Create an installer for a standalone application on a Windows system.
Write a MATLAB function that generates a magic square. Save the function in a file named
mymagic.m.
function out = mymagic(in)
out = magic(in)Build a standalone application using the mcc command.
mcc -m mymagic.m
buildresult.json includedSupportPackages.txt mccExcludedFiles.log mymagic.exe readme.txt requiredMCRProducts.txt unresolvedSymbols.txt
Create an installer for the standalone application using the
compiler.package.installer
function.
compiler.package.installer("mymagic.exe",... "buildresult.json",... "ApplicationName","MagicSquare_Generator")
MyAppInstaller within a folder named
MagicSquare_Generatorinstaller.Customize an installer for a standalone application using name-value arguments.
Build a standalone application using the
compiler.build.standaloneApplication command.
copyfile(fullfile(matlabroot,"extern","examples","compiler","magicsquare.m")); buildResults = compiler.build.standaloneApplication("magicsquare.m");
Save the path to the generated buildresult.json
file.
runtimeProducts = fullfile(buildResults.Options.OutputDir,"buildresult.json")
Save the list of files from the standalone application build results.
fileList = buildResults.Files
fileList = [fileList; {'UsageNotes.txt'}];Create an installer for the standalone application using the
compiler.package.installer function. Optionally, you can add
additional files to the installer using the AdditionalFiles. These
files are installed in the installation directory along with the application
executable.
compiler.package.installer(fileList, runtimeProducts,... "ApplicationName","CustomMagicSquare",... "AdditionalFiles","UsageNotes.txt",... "InstallerName","Installer_With_Addl_Files",... "Summary","See UsageNotes.txt for info.")
Customize an installer for a standalone application on a Windows system using an InstallerOptions object.
Create an InstallerOptions object.
opts = compiler.package.InstallerOptions("ApplicationName","MagicSquare_Generator",... "AuthorCompany","Boston Common",... "AuthorName","Frog",... "InstallerName","MagicSquare_Installer",... "Summary","Generates a magic square.")
Pass the InstallerOptions object as an input to the
function.
compiler.package.installer("mymagic.exe","buildresults.json","Options",opts)
Input Arguments
Build results, specified as a compiler.build.Results object. Create the
Results object by saving the output from a
compiler.build function.
List of files and folders for installation, specified as a character vector, a
string scalar, a cell array of character vectors, or a string array. These files are
typically generated by the mcc command or a
compiler.build function and can also include any additional files
and folders required by the installed application to run. Additional files are installed
in the installation directory along with the application executable.
Files generated in a particular release can be packaged using the
compiler.package.installerfunction of the same release.Files of type
.ctfon one operating system can be packaged using thecompiler.package.installerfunction on a different operating system, as long as the build command and thecompiler.package.installerfunction are from the same release.
Example: {'mymagic.exe','UsageNotes.txt'}
Data Types: char | string
Path to the buildresult.json file, specified as a character
vector or string scalar. This file is generated by MATLAB
Compiler™. The path can be relative to the current working directory or absolute.
In releases prior to R2025a, use requiredMCRProducts.txt
instead of buildresult.json.
Example: "D:\Documents\MATLAB\work\MagicSquare\buildresult.json"
Data Types: char | string
Name of the installed application, specified as a character vector or a string scalar.
Example: "MagicSquare_Generator"
Data Types: char | string
Installer options, specified as an InstallerOptions
object.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=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.
Before R2021a, use commas to separate each name and value, and enclose
Name in quotes.
Example: "Version","9.5" specifies the version of the installed
application.
Since R2023a
Additional files and folders to be installed with the application, specified as a character vector, a string scalar, a string array, or a cell array of character vectors. Paths can be relative to the current working directory or absolute.
Example: "AdditionalFiles",["myimage.png","data.mat"]
Data Types: char | string | cell
Since R2023a
Add or remove programs icon, specified as a character vector or string scalar. The image is used as the icon in the list of Windows applications within settings. Paths can be relative to the current working directory or absolute.
The default path is:
"matlabroot\toolbox\compiler\packagingResources\default_icon_48.png"Example: "AddRemoveProgramsIcon","win_icon.png"
Data Types: char | string
Name of installed application, specified as a character vector or a string scalar.
Example: "ApplicationName","MagicSquare_Generator"
Data Types: char | string
Name of company that created the application, specified as a character vector or a string scalar.
Example: "AuthorCompany","Boston Common"
Data Types: char | string
Email address of the application author, specified as a character vector or a string scalar.
Example: "AuthorEmail","frog@example.com"
Data Types: char | string
Name of application author, specified as a character vector or a string scalar.
Example: "AuthorName","Frog"
Data Types: char | string
Default directory where you want the installer to install the application, specified as a character vector or a string scalar.
If no path is specified, the default path for each operating system is:
| Operating System | Default Installation Directory |
|---|---|
| Windows | C:\Program
Files\ |
| Linux® | /usr/ |
| macOS | /Applications/ |
Example: "DefaultInstallationDir","C:\Users\MW_Programs\MagicSquare_Generator"
Data Types: char | string
Detailed description of the application, specified as a character vector or a string scalar.
Example: "Description","The MagicSquare_Generator application
generates an n-by-n matrix constructed from the integers 1 through n2 with
equal row and column sums."
Data Types: char | string
Notes about additional requirements for using application, specified as a character vector or a string scalar.
Example: "InstallationNotes","This is a Linux
installer."
Data Types: char | string
Path to an image file used as the icon for the installed application, specified as a character vector or a string scalar.
The default path is:
"matlabroot\toolbox\compiler\packagingResources\default_icon_48.png"Example: "InstallerIcon","D:\Documents\MATLAB\work\images\myIcon.png"
Path to an image file used as the installer logo, specified as a character vector or a string scalar. The logo will be resized to 112 pixels by 290 pixels.
The default path is:
"matlabroot\toolbox\compiler\packagingResources\default_logo.png"Example: "InstallerLogo","D:\Documents\MATLAB\work\images\myLogo.png"
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: "InstallerName","MagicSquare_Installer"
Path to an image file used as the installer splash screen, specified as a character vector or a string scalar. The splash screen icon will be resized to 400 pixels by 400 pixels.
The default path is:
"matlabroot\toolbox\compiler\packagingResources\default_splash.png"Example: "InstallerSplash","D:\Documents\MATLAB\work\images\mySplash.png"
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"
Data Types: char | string
Path to folder where the installer is saved, specified as a character vector or a string scalar.
If no path is specified, the default path for each operating system is:
| Operating System | Default Installation Directory |
|---|---|
| Windows | .\ |
| Linux | ./ |
| macOS | ./ |
The . in the directories listed above
represents the present working directory.
Example: "OutputDir","D:\Documents\MATLAB\work\MagicSquare"
Since R2024a
Choice on the file type of the generated installer.
"auto"— Option for installer to automatically select the suitable package 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 generate a ZIP file as an output when creating a new installer. This option is only supported on Windows.
Example: "PackageType","zip"
Data Types: char | string
Since R2024a
MATLAB Runtime delivery option, specified as one of the following:
"web"— Option for the installer to download MATLAB Runtime from the MathWorks® website during application installation. This option is the default behavior."installer"— Option to include MATLAB Runtime 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 might not have access to the internet."none"— Option to not install MATLAB Runtime during application installation. Use this option if you think your end user will install MATLAB Runtime using another method. (since R2024a)
Note
If you use either the "web" or
"installer" option, the full MATLAB Runtime will be installed. To create a
minimal MATLAB Runtime installer that can run one or more specific
MATLAB
Compiler applications, see compiler.runtime.customInstaller. (since R2024b)
Example: "RuntimeDelivery","installer"
Data Types: char | string
Path to a file or folder that the installer will create a shortcut to at install time, specified as a character vector or a string scalar.
Example: "Shortcut",".\mymagic.exe"
Data Types: char | string
Summary description of the application, specified as a character vector or a string scalar.
Example: "Summary","Generates a magic
square."
Data Types: char | string
Version number of the installed application, specified as a character vector or a string scalar.
Example: "Version","2.0"
Data Types: char | string
Since R2023b
Flag to control output verbosity, specified as "on" or
"off", or as numeric or logical 1
(true) or 0
(false). A value of "on" is equivalent to
true, and "off" is equivalent to
false. Thus, you can use the value of this property as a
logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState.
If you set this property to
"on", then the MATLAB command window displays progress information indicating compiler output during the packaging process.If you set this property to
"off", then the command window does not display progress information. This is the default behavior.
Example: "Verbose","on"
Data Types: logical
Tips
The installer created by this function installs your MATLAB Compiler generated artifacts and optionally the full MATLAB Runtime. To create a minimal MATLAB Runtime installer that can run one or more specific MATLAB Compiler applications, see
compiler.runtime.customInstaller.Installers that contain MATLAB Runtime require access to the full MATLAB Runtime installer at the same version and update level as the version of MATLAB used to create them. Use the
compiler.runtime.downloadfunction to obtain the MATLAB Runtime installer at the same release and update level.
Version History
Introduced in R2020aYou can use the OptionalDependencies option to control whether to
include all of the optional MATLAB Runtime dependencies in the installer.
You can use the JSON file named buildresult.json in place of
requiredMCRProducts.txt in deployment workflows. The
requiredMCRProducts.txt file will be removed in a future
release.
You can use the PackageType option to choose whether the installer is
packaged as a ZIP file if the installer size is less than 2GB on Windows. By default, a ZIP installer is created only when the installer size exceeds 2
GB.
You can use the RuntimeDelivery option with the value set to
"none" to not install MATLAB Runtime during application installation. Use this option if you think your end user
will install MATLAB Runtime using another method.
You can use the Verbose option to control output verbosity.
You can use the AdditionalFiles option to specify additional files to
include in the installer.
You can use the AddRemoveProgramsIcon option to specify the image
used as the icon in the list of Windows applications within settings.
You can use the SupportPackages option to specify support packages to
include in the deployable code archive.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)