Once you generate code from your Simulink® model, you can relocate the code to another development environment using the pack-and-go utility. Use this utility when the development environment does not have the MATLAB® and Simulink products.
The pack-and-go utility uses the tools for customizing the build process after code
generation and a
packNGo (Simulink Coder) function to find and package files
for building an executable image. The files are packaged in a compressed file that you
can relocate and unpack using a standard zip utility.
You can package the code using either the user interface or the command-line interface. The command-line interface provides more control over the details of code packaging. For more information on each of these methods, see Relocate Code to Another Development Environment (Simulink Coder).
This example shows how to package the executable generated from the
ex_codegen_dsp model in the Generate C Code from Simulink Model
example using the user interface. You can also generate and package a static library
file or a dynamic library file.
Open the model by running the following command in the MATLAB command prompt.
To package and relocate code for your model using the user interface:
In the Modeling tab, click Model Settings. The Configuration Parameters dialog opens. Navigate to the Code Generation tab.
To package the executable along with the source code, clear
Generate code only check box and select the option
Package code and artifacts (Simulink Coder). This option
configures the build process to run the
packNGo (Simulink Coder) function after code
generation to package generated code and artifacts for relocation.
In the Zip file
name (Simulink Coder) field, enter the name of the zip file in
which to package generated code and artifacts for relocation. In this
example, the name of the zip file is
You can specify the file name with or without the
extension. If you specify no extension or an extension other than
.zip, the zip utility adds the
extension. If you do not specify a value, the build process uses the name
is the name of
the top model for which code is being generated.
Click Apply. In the C Code tab
of the model toolstrip, click the Build Model icon
(). If the C Code tab
is not open, in the Apps gallery of the model
toolstrip, click Simulink Coder. The C
Code tab appears. When you click on the Build
Model icon (), the code generator builds the
executable, generates the Code Generation Report and
places the executable in the current working folder. Note that the build
process creates a new subfolder called
ex_codegen_dsp_grt_rtw in your current MATLAB working folder. This subfolder contains the generated source
code files. In addition, you can also see
lmsAdaptFilt.zip file in the current directory. The
zip files contains the
the executable, and other additional dependency source files required to run
the executable without Simulink and MATLAB installed.
Relocate the zip file to the destination development environment and unpack the file to run the executable.
If your model contains any blocks mentioned in How To Run a Generated Executable Outside MATLAB,
the executable generated from the model requires certain prebuilt dynamic library
.dll) files. These
.dll files are shipped
with MATLAB. To package code that runs on an environment without MATLAB and Simulink installed, the Simulink
Coder™ packages these
.dll files into the