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:
- Export a standalone FMU from Simulink with source code in the desired language (C/C++).
- Unzip the resulting .fmu file to access the "sources", "binaries", and "documentation" folders.
- Open the documentation/index.html page to find the commands to regenerate the binaries on Linux, Windows, and macOS platforms.
- Download the required FMI standard headers as explained in this MATLAB Answer.
- 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.
- Place the generated binary file in the "binaries" folder.
- 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.