Main Content

Create Deployable Archive for MATLAB Production Server

Supported platform: Windows®, Linux®, Mac

Note

To create a deployable archive, you need an installation of the MATLAB® Compiler SDK™ product.

This example shows how to create a deployable archive using a MATLAB function. You can then deploy the generated archive on MATLAB Production Server™.

Create MATLAB Function

In MATLAB, examine the MATLAB program that you want to package.

For this example, write a function addmatrix.m as follows.

function a = addmatrix(a1, a2)

a = a1 + a2;

At the MATLAB command prompt, enter addmatrix([1 4 7; 2 5 8; 3 6 9], [1 4 7; 2 5 8; 3 6 9]).

The output is:

 ans =
     2     8    14
     4    10    16
     6    12    18

Create Deployable Archive with Production Server Compiler App

Package the function into a deployable archive using the Production Server Compiler app. Alternatively, if you want to create a deployable archive from the MATLAB command window using a programmatic approach, see Create Deployable Archive Using compiler.build.productionServerArchive.

  1. To open the Production Server Compiler app, type productionServerCompiler at the MATLAB prompt.

    Alternatively, on the MATLAB Apps tab, on the far right of the Apps section, click the arrow. In Application Deployment, click Production Server Compiler. In the Production Server Compiler project window, click Deployable Archive (.ctf).

  2. In the Production Server Compiler project window, specify the main file of the MATLAB application that you want to deploy.

    1. In the Exported Functions section, click the Add button.

    2. In the Add Files window, browse to the example folder, and select the function you want to package.

      Click Open.

    Doing so adds the function addmatrix.m to the list of main files.

    Production Server Compiler with Deployable Archive (.ctf) type selected and addmatrix.m in the exported functions section

Customize Application and Its Appearance

Customize your deployable archive and add more information about the application.

  • Archive information — Editable information about the deployed archive.

  • Additional files required for your archive to run — Additional files required to run the generated archive. These files are included in the generated archive installer. See Manage Required Files in Compiler Project.

  • Files packaged for redistribution — Files that are installed with your archive. These files include:

    • Generated deployable archive

    • Generated readme.txt

    See Specify Files to Install with Application.

  • Include MATLAB function signature file — Add or create a function signature file to help clients use your MATLAB functions. See MATLAB Function Signatures in JSON.

Production Server Compiler with the archive name set to addmatrix

Package Application

  1. To generate the packaged application, click Package.

    In the Save Project dialog box, specify the location to save the project.

    Package window that says Creating Binaries. The option labeled Open output folder when process completes is checked.

  2. In the Package dialog box, verify that Open output folder when process completes is selected.

    When the deployment process is complete, examine the generated output.

    • for_redistribution — Folder containing the archive archiveName.ctf

    • for_testing — Folder containing the raw generated files to create the installer

    • PackagingLog.html — Log file generated by MATLAB Compiler SDK

Create Deployable Archive Using compiler.build.productionServerArchive

As an alternative to the Production Server Compiler app, you can create a deployable archive using a programmatic approach.

  • Build the deployable archive using the compiler.build.productionServerArchive function.

    Optionally, you can add a function signature file to help clients use your MATLAB functions. For more details, see MATLAB Function Signatures in JSON.

    buildResults = compiler.build.productionServerArchive('addmatrix.m',...
    'FunctionSignatures','addmatrixFunctionSignatures.json',...
    'Verbose','on');
    buildResults = 
    
      Results with properties:
    
                      BuildType: 'productionServerArchive'
                          Files: {'/home/mluser/Work/magicarchiveproductionServerArchive/addmatrix.ctf'}
        IncludedSupportPackages: {}
                        Options: [1×1 compiler.build.ProductionServerArchiveOptions]

    You can specify additional options in the compiler.build command by using name-value arguments. For details, see compiler.build.productionServerArchive.

    The compiler.build.Results object buildResults contains information on the build type, generated files, included support packages, and build options.

    The function generates the following files within a folder named addmatrixproductionServerArchive in your current working directory:

    • addmatrix.ctf — Deployable archive file.

    • includedSupportPackages.txt — Text file that lists all support files included in the assembly.

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

    • readme.txt — Text file that contains packaging and deployment information.

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

    • unresolvedSymbols.txt — Text file that contains information on unresolved symbols.

Compatibility Considerations

In most cases, you can generate the deployable archive on one platform and deploy to a server running on any other supported platform. Unless you add operating system-specific dependencies or content, such as MEX files or Simulink® simulations to your applications, the generated archives are platform-independent.

See Also

Functions

Apps

Related Topics