Importing FMU into a Simulink model

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

Réponses (2)

Aditya
Aditya le 17 Déc 2025

0 votes

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.
Bence
Bence le 19 Mai 2026 à 7:58

0 votes

Hi,
I think the workflow you are looking for is supported since R2025a, according to this documentation page: Integrate FMI APIs in Generated Code Using FMU Source Code or Binary - MATLAB & Simulink

Catégories

En savoir plus sur Deploy Standalone Applications dans Centre d'aide et File Exchange

Question posée :

le 4 Déc 2025

Réponse apportée :

le 19 Mai 2026 à 7:58

Community Treasure Hunt

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

Start Hunting!

Translated by