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 18Create Deployable Archive Using compiler.build.productionServerArchive
Package the function into a deployable archive using a programmatic approach. Alternatively, if you want to create a deployable archive using a graphical approach, see Create MATLAB Production Server Archive Using Production Server Archive Compiler App (MATLAB Compiler SDK).
Build the deployable archive using the
compiler.build.productionServerArchivefunction.Optionally, you can add a function signature file to help clients use your MATLAB functions. For more details, see MATLAB Function Signatures in JSON.
Note
compiler.build.productionServerArchivedoes not support semantic versioning. Attempting to build a deployable archive from a MATLAB function with a name containing the "." character will result in an error.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] RuntimeDependencies: [1×1 compiler.runtime.Dependencies]You can specify additional options in the
compiler.buildcommand by using name-value arguments. For details, seecompiler.build.productionServerArchive(MATLAB Compiler SDK).The
compiler.build.ResultsobjectbuildResultscontains information on the build type, generated files, included support packages, and build options.The build function generates files within a folder named
addmatrixproductionServerArchivein your current working directory. For information on the files generated, see .
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. For releases before R2019b, compile deployable archives on the same platform as the server you will be running them on. (since R2019b)
See Also
Functions
compiler.build.productionServerArchive(MATLAB Compiler SDK) |mcc(MATLAB Compiler)
Topics
- Create MATLAB Production Server Archive Using Production Server Archive Compiler App (MATLAB Compiler SDK)
- Testing and Debugging RESTful APIs and Java Clients with the Development Version of MATLAB Production Server (MATLAB Compiler SDK)
- Deploy Archive to MATLAB Production Server
- MATLAB Function Signatures in JSON
- JSON Representation of MATLAB Data Types