Importing FMU into a Simulink model

25 views (last 30 days)
HiL SW
HiL SW on 4 Dec 2025 at 5:10
Answered: Aditya on 17 Dec 2025 at 6:26
We have a scenario where FMU is incorporated into a Simulink R2024A and exported it as a .slx. We have a Linux target where it is throwing error as "fatal error: rtwcg_fmu2_target.h: No such file or directory" when we compile them in our product.
  1. We need to know if this is a valid use case.
  2. If we try to include this file, we are getting other dependency files are not there.
How do we solve this issue

Answers (1)

Aditya
Aditya on 17 Dec 2025 at 6:26
Hi,
Answering your questions.
1) No, this is not a standard or supported workflow.
  • FMU (Functional Mock-up Unit) blocks in Simulink are meant for simulation within Simulink, not for direct code generation and deployment as .slx models to external (Linux) targets.
  • The generated code from a Simulink model that includes FMU blocks depends on MathWorks-internal support files (like rtwcg_fmu2_target.h), which are not open-source or distributed for external compilation.
Following are a few workarounds for the same
1. Simulation-only:
If you need to use FMUs, run the simulation inside Simulink. Code generation and deployment to external targets is not supported for FMU blocks.
2. For code generation/deployment:
  • Remove FMU blocks from your model before generating code for deployment.
  • If you need the FMU logic on your Linux target, consider:
  • Running the FMU directly on Linux using an FMU runtime/library (e.g., FMPy, PyFMI, or C FMI APIs).
  • Wrap the FMU as a C/C++ library and interface with your application, bypassing Simulink code generation.

Categories

Find more on Deploy Standalone Applications in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!