# compiler.build.standaloneWindowsApplication

Create a standalone application for deployment outside MATLAB that does not launch a Windows command prompt

## Syntax

``compiler.build.standaloneWindowsApplication(AppFile)``
``compiler.build.standaloneWindowsApplication(AppFile,Name,Value)``
``compiler.build.standaloneWindowsApplication(opts)``
``results = compiler.build.standaloneWindowsApplication(___)``

## Description

example

``` CautionThis function is only supported on Windows® operating systems. `compiler.build.standaloneWindowsApplication(AppFile)` creates a standalone Windows only application using a MATLAB® function, class, or app specified by `AppFile`. The application does not open a Windows command prompt on execution, and as a result, no console output is displayed. The executable file extension on Windows is `.exe`.```

example

````compiler.build.standaloneWindowsApplication(AppFile,Name,Value)` creates a standalone Windows application with additional options specified as one or more name-value pairs. Options include the executable name, version number, and icon and splash images.```

example

````compiler.build.standaloneWindowsApplication(opts)` creates a standalone Windows application with additional options specified by a `compiler.build.StandaloneApplicationOptions` object `opts`. If you use a `StandaloneApplicationOptions` object, you cannot specify any other options using name-value pairs.```

example

````results = compiler.build.standaloneWindowsApplication(___)` returns build information as a `compiler.build.Results` object using any of the input arguments in previous syntaxes. Build information includes the build type, paths to the compiled files, and build options.```

## Examples

collapse all

Create a graphical standalone application that displays a plot on a Windows system.

Write a MATLAB function that plots the values `1` to `10`. Save the function in a file named `myPlot.m`.

```function myPlot() plot(1:10)```

Build a standalone Windows application using the `compiler.build.standaloneWindowsApplication` command.

`compiler.build.standaloneWindowsApplication('myPlot.m');`

This generates the following files within a folder named `myPlotstandaloneApplication` in your current working directory:

• `myPlot.exe`—Executable file.

• `mccExcludedFiles.log`—Log file that contains a list of any toolbox functions that were not included in the application. For more information on non-supported functions, see MATLAB Compiler Limitations.

• `readme.txt`—Readme file that contains information on deployment prerequisites and the list of files to package for deployment.

• `requiredMCRProducts.txt`—Text file that contains product IDs of products required by MATLAB Runtime to run the application.

• `splash.png`—File that contains the splash image that displays when the application is run.

To run `myPlot.exe`, execute `!myPlotstandaloneApplication\myPlot.exe` in the MATLAB command window or execute `myPlot.exe` at the Windows command prompt. The application displays a splash image followed by a MATLAB figure of a line plot.

Figure 1 (myPlot.exe)

Customize a graphical standalone application on a Windows system using name-value pairs to specify the executable name and automatically include a MAT-file.

Create `xVal` as a vector of linearly spaced values between 0 and 2π. Use an increment of π/40 between the values. Create `yVal` as sine values of x. Save the variables in a MAT-file named `myVars.mat`.

```xVal = 0:pi/40:2*pi; yVal = sin(xVal); save('myVars.mat','xVal','yVal');```

Create a function file named `myPlot.m` to create a line plot of the `xVal` and `yVal` variables.

```function myPlot() load('myVars.mat'); plot(1:10)```

Build the standalone application using name-value pair arguments to specify additional options.

```compiler.build.standaloneWindowsApplication('myPlot.m',... 'AutoDetectDataFiles','On',... 'ExecutableName','SineWaveApp')```

The following files are generated within a folder named `SineWaveAppstandaloneApplication` in your current working directory:

• `SineWaveApp.exe`

• `mccExcludedFiles.log`

• `readme.txt`

• `requiredMCRProducts.txt`

• `splash.png`

To run `SineWaveApp.exe`, double-click `SineWaveApp.exe` from the file browser, execute `!SineWaveAppstandaloneApplication\SineWaveApp.exe` in the MATLAB command window, or execute `SineWaveApp.exe` at the Windows command prompt.

The application displays a splash image followed by a MATLAB figure of a sine wave plot.

Figure 1 (SineWaveApp.exe)

Customize multiple standalone Windows applications using a `compiler.build.StandaloneApplicationOptions` object on a Windows system to specify a common output directory and display progress information during the build process.

Write a MATLAB function that plots the values `1` to `10`. Save the function in a file named `myPlot.m`.

```function myPlot() plot(1:10)```

Create a `StandaloneApplicationOptions` object using `myPlot.m` and additional options specified as name-value pairs.

```opts = compiler.build.StandaloneApplicationOptions('myPlot.m',... 'OutputDir','D:\Documents\MATLAB\work\WindowsApps',... 'Verbose','On')```
```opts = StandaloneApplicationOptions with properties: ExecutableName: 'myPlot' CustomHelpTextFile: '' EmbedArchive: on ExecutableIcon: 'C:\Program Files\MATLAB\R2020b\toolbox\compiler\resources\default_icon_48.png' ExecutableSplashScreen: 'C:\Program Files\MATLAB\R2020b\toolbox\toolbox\compiler\resources\default_splash.png' ExecutableVersion: '1.0.0.0' AppFile: 'myPlot.m' TreatInputsAsNumeric: on AdditionalFiles: {} AutoDetectDataFiles: on OutputDir: 'D:\Documents\MATLAB\work\WindowsApps' Verbose: on```

Pass the `StandaloneApplicationOptions` object as an input to the build function.

`compiler.build.standaloneWindowsApplication(opts);`

Use dot notation to change the input file of an existing `StandaloneApplicationOptions` object.

`opts.AppFile = 'myPlot2.m';`

This allows you to compile multiple applications using the same options object.

Create a standalone Windows application and save information about the build type, included files, and build options to a `compiler.build.Results` object on a Windows system.

Save the `compiler.build.standaloneWindowsApplication` information to a `Results` object by declaring an output variable.

`results = compiler.build.standaloneWindowsApplication('mymagic.m','AdditionalFiles',["myvars.mat","mysubfunction.m"])`
```results = Results with properties: BuildType: 'standaloneWindowsApplication' Files: {3×1 cell} Options: [1×1 compiler.build.StandaloneApplicationOptions]```

The `Files` property contains the paths to the generated standalone executable, splash image, and readme files.

## Input Arguments

collapse all

Path to the main file used to build the application, specified as a row character vector or a string scalar. The file must be a MATLAB function, class, or app of one of the following types: `.m`, `.p`, `.mlx`, `.mlapp`, or a valid MEX file.

Example: `'mymagic.m'`

Data Types: `char` | `string`

Standalone application build options, specified as a `compiler.build.StandaloneApplicationOptions` object.

### Name-Value Pair Arguments

Specify optional comma-separated pairs of `Name,Value` arguments. `Name` is the argument name and `Value` is the corresponding value. `Name` must appear inside quotes. You can specify several name and value pair arguments in any order as `Name1,Value1,...,NameN,ValueN`.

Example: `'EmbedArchive','on'`

Additional files to be included in the standalone application, specified as a character vector, a string scalar, a string array, or a cell array of character vectors. File paths can be relative to the current working directory or absolute.

Example: `'AdditionalFiles',["myvars.mat","myfunc.m"]`

Data Types: `char` | `string` | `cell`

Flag to automatically include data files, 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 data files that are provided as inputs to certain functions (`load`, `fopen`, etc) are automatically included in the standalone application.

• If you set this property to `'off'`, then data files must be added to the application using the `AdditionalFiles` property.

Example: `'AutoDetectDataFiles','Off'`

Data Types: `logical`

Path to a help file containing help text for the end user of the application, specified as a character vector or a string scalar. The path can be relative to the current working directory or absolute.

Example: `'CustomHelpTextFile','D:\Documents\MATLAB\work\helpfile.txt'`

Data Types: `char` | `string`

Flag to embed the standalone archive, 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 standalone archive is embedded into the standalone executable.

• If you set this property to `'off'`, then the standalone archive is generated as a separate file.

Note

This property is ignored for Java libraries.

Example: `'EmbedArchive','Off'`

Data Types: `logical`

Path to an icon image, specified as a character vector or a string scalar. The image is used as the icon for the standalone application executable. The path can be relative to the current working directory or absolute. Accepted image types are `.jpg`, `.jpeg`, `.png`, `.bmp`, and `.gif`.

Example: `'ExecutableIcon','D:\Documents\MATLAB\work\images\myIcon.png'`

Data Types: `char` | `string`

Name of the generated application, specified as a character vector or a string scalar. The default value is the file name of `AppFile`. Target output names must begin with a letter or underscore character and contain only alpha-numeric characters or underscores.

Example: `'ExecutableName','MagicSquare'`

Data Types: `char` | `string`

Path to the splash image, specified as a character vector or a string scalar. The image is used as the splash screen for the standalone application. The path can be relative to the current working directory or absolute. Accepted image types are `.jpg`, `.jpeg`, `.png`, `.bmp`, and `.gif`. The image is resized to 400 pixels by 400 pixels.

Example: `'ExecutableSplashScreen','D:\Documents\MATLAB\work\images\mySplash.png'`

Data Types: `char` | `string`

Executable version, specified as a character vector or a string scalar.

Note

This is only used on Windowsoperating systems.

Example: `'ExecutableVersion','4.0'`

Data Types: `char` | `string`

Path to the output directory where the build files are saved, specified as a character vector or a string scalar. The path can be relative to the current working directory or absolute.

If no path is specified, a build folder named `ExecutableNamestandaloneApplication` is created in the current working directory.

Example: `'OutputDir','D:\Documents\MATLAB\work\MagicSquarestandaloneApplication'`

Data Types: `char` | `string`

Flag to interpret command line inputs as numeric values, 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 command line inputs are treated as numeric MATLAB doubles.

• If you set this property to `'off'`, then command line inputs are treated as MATLAB character vectors.

Example: `'TreatInputsAsNumeric','On'`

Data Types: `logical`

Flag to control build 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 code generation stages and compiler output during the build process.

• If you set this property to `'off'`, then the command window does not display progress information.

Example: `'Verbose','On'`

Data Types: `logical`

## Output Arguments

collapse all

Build results, returned as a `compiler.build.Results` object. The `Results` object contains the build type, the paths to the compiled files, and the build options, specified as a `StandaloneApplicationOptions` object.

## Limitations

• This function is only supported on Windows operating systems.

• The application does not open a Windows command prompt on execution, and as a result, no console output is displayed.

Introduced in R2020b

Get trial now