Build Out of the Box Linux Executable from AUTOSAR Adaptive Model
R2026bAs part of generating code for an AUTOSAR adaptive model, you can generate a
CMakeLists.txt file for building a Linux® standalone executable. Then, on a Linux system, you can build the executable and run the resulting executable on
Linux as a standalone application.
For models using the service interface modeling pattern, configure deployment properties
(such as service instance IDs, domain IDs, and logging options) through the
Property Inspector in the AUTOSAR architecture model before
building. When you build, the software automatically generates the
ServiceInstanceManifest.json and
ExecutionManifest.json files alongside the C++ code and ARXML
files.
If the applications have matching DDS deployment artifacts, they can
communicate with each other. Building the executable files from
CMakeLists.txt requires running CMake software on a Linux system.
Note
Executable generation from an AUTOSAR adaptive model is supported only on the Linux platform.
To build a Linux standalone executable:
Open a component model that you have configured for the AUTOSAR adaptive target (
autosar_adaptive.tlc). The component model must be referenced from an AUTOSAR architecture model where you have configured the platform (Adaptive Platform), network binding (DDSorSOME/IP), and deployment properties.In the Configuration Parameters dialog box, select Code Generation > Build process > Toolchain settings. Set Toolchain to
AUTOSAR Adaptive Linux Executable. The toolchain selection adds ARA functional cluster libraries provided by MathWorks®.Note
The
AUTOSAR Adaptive Linux Executabletoolchain is supported only if the Embedded Coder® Support Package for Service-Oriented Applications on Linux is installed. For more information, see Install Embedded Coder Support Package for Service-Oriented Applications on Linux (Embedded Coder).Build the model. The build generates C++ code, ARXML files, a
CMakeLists.txtfile, and manifest JSON files (ServiceInstanceManifest.jsonandExecutionManifest.json).In the model build folder, open
CMakeLists.txtand verify that it is configured for executable generation. For example, make sure that:The
CMakeLists.txtfile containsadd_executable(modelName …).The specifications for
target_include_directories,target_link_libraries, andlink_directoriesinclude the values specified in Toolchain settings.
Verify the
DDSdeployment artifacts from the generatedServiceInstanceManifest.arxmlfile, includingDDS Topic Name,DDS Domain ID, event deployments, and DDS QoS configuration (USER_DATA and Partition QoS). These values are derived from the deployment specification configured in the architecture model Property Inspector.Get the support package root directory path using the below command in MATLAB:
Copy the path to use it in the next step.path = matlabshared.supportpkg.getSupportPackageRoot
On a Linux system, outside MATLAB®, go to the model build folder. To build the executable file, enter these commands:
cmake -DSPKG_ROOT=<path from step 6> CMakeLists.txt; make all;
Or, if MATLAB is running on Linux, in the Command Window, run the command
codebuild(<pathToExeFolder>), where the argument is the path to the exe folder in the build directory. For example:Internally, thecodebuild('pathToExeFolder');codebuildcommand also runs thecmakeandmakecommands.
The make command generates an executable file for the adaptive model
one level above the model build folder. You can run the executable on Linux as a standalone application. Before running the executable, verify that the
generated manifest JSON files (ServiceInstanceManifest.json and
ExecutionManifest.json) are present in the directory from which you
run the executable. These files configure runtime behavior such as DDS communication and
logging.
For AUTOSAR-compliant DDS communication, adaptive applications must have matching
TOPIC-NAME, DOMAIN-ID, compatible USER_DATA QoS
(service identity and version), and matching Partition QoS strings. For communication with
raw DDS applications that do not use AUTOSAR QoS policies, set
UseDDS_QosConfiguration to false in the deployment
specification, which falls back to topic-name and domain-ID matching only.