Undefined identifier when using LibMdlStartCustomCode

4 views (last 30 days)
Hi,
I'm using the function LibMdlStartCustomCode in a tlc file:
%<LibMdlStartCustomCode("aaa","trailer")>
However, I obtain the following error message at code generation:
Error: File: C:\Program Files\MATLAB\R2021b\rtw\c\tlc\mw\hookslib.tlc Line: 320 Column: 22
Undefined identifier System
Main program:
==> [00] C:\Program Files\MATLAB\R2021b\rtw\c\tlc\mw\hookslib.tlc:LibMdlStartCustomCode(320)
do anyone have an idea what is going on ?

Answers (1)

Kausthub
Kausthub on 6 Oct 2023
Hi Stéphane,
I understand that you are facing an error while generating code using a custom TLC file which contains the LibMdlStartCustomCodefunction.
The provided error message tells us that the identifier “System” is undefined (https://www.mathworks.com/help/rtw/tlc/tlc-error-messages.html). You get this error because System is not part of CompiledModel" which means that “System” is missing from your model.rtw file.
Some points to be noted:
  • “System” is defined in the “model.rtw file and does not require any additional assignment in the TLC file.
  • Please verify whether “System” is defined in the “model.rtw" file and check whether NumSystems” is greater than 0.
  • There is one “System” for each nonvirtual subsystem in your Simulink model. So, please ensure that your model contains at least one nonvirtual subsystem.
Here are few resources that might give a better understanding of the issue:
Hope this helps and solves your error!

Categories

Find more on Simulink in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!