Main Content

compiler.runtime.customInstaller

Create a MATLAB Runtime installer for the specified files generated by MATLAB Compiler

Since R2024b

Description

compiler.runtime.customInstaller(installerName, results) 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 any compiler.build function.

example

compiler.runtime.customInstaller(installerName, filepath) creates a MATLAB Runtime installer using a list of requiredMCRProducts.txt files generated by MATLAB Compiler.

example

compiler.runtime.customInstaller(___,Name=Value) 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.

example

Examples

collapse all

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 file magicsquare.m.

copyfile(fullfile(matlabroot,"extern","examples","compiler","magicsquare.m"));

Create a standalone application using compiler.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 select MATLAB 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 file magicsquare.m.

copyfile(fullfile(matlabroot,"extern","examples","compiler","magicsquare.m"));

Create a standalone application using compiler.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 by MATLAB Compiler.

Write a MATLAB function to package into a standalone Windows application. For this example, copy the MATLAB script flames.m and data file flames.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 using compiler.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 the customInstallers folder in the current working directory.

Deploy the MATLAB Runtime installer and shared library files (.ctf and .hpp) to the target machine.

Input Arguments

collapse all

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 build results created by a compiler.build function, such as compiler.build.standaloneApplication or compiler.build.productionServerArchive (MATLAB Compiler SDK), specified as a vector of compiler.build.Results objects.

Example: [results1,results2]

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 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.

Example:

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 of installerName.

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 on Windows.

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.

  • 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