How can I cross-compile a standalone FMU that I exported from Simulink with Simulink Compiler?

26 ビュー (過去 30 日間)
I would like to reuse a standalone FMU generated with Simulink Compiler™ on another platform. For example, adding Linux binaries when a Simulink model is exported to FMU on Windows platform.

採用された回答

MathWorks Support Team
MathWorks Support Team 2025 年 10 月 6 日 0:00
編集済み: MathWorks Support Team 2025 年 10 月 6 日 12:53

R2024a Feature: FMU export with Linux binaries on Windows

Starting from MATLAB R2024a, Windows users can directly export FMUs with Linux x86-64 binaries using an integrated workflow with Windows Subsystem for Linux (WSL2). For more information, see:

Manual Cross-Compilation of FMUs:

For users working with versions earlier than MATLAB R2024a, or those requiring different host and target platforms, a manual cross-compilation process is required.
You can refer to the following documentation link, which contains a full example of how to export the Simulink model to a standalone FMU with source code and cross-compile the binary for Linux x86-64 using g++:
Here’s a general overview of the steps involved in manually cross-compiling an FMU generated from Simulink: 
  1. Export a standalone FMU from Simulink with source code in the desired language (C/C++).
  2. Unzip the resulting .fmu file to access the "sources", "binaries", and "documentation" folders.
  3. Open the documentation/index.html page to find the commands to regenerate the binaries on Linux, Windows, and macOS platforms.
  4. Download the required FMI standard headers as explained in this MATLAB Answer.
  5. Run the command listed under the section ‘Build command for Linux using gcc/g++’. If you are targeting a 64-bit Linux platform, you should run the compilation command on a 64-bit Linux machine. For other target platforms, use a suitable cross-compiler (or move the files to a different platform for compilation) and adjust the build script.
  6. Place the generated binary file in the "binaries" folder.
  7. Repackage the FMU.
Additional Note:
If the goal is to deploy the FMU to a Speedgoat target, the end user can apply the slrealtime.fmu.compileFMUSources cross-compilation function which ships with Simulink Real-Time.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTroubleshooting in Simulink Real-Time についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by