Undefined identifier when using LibMdlStartCustomCode
Show older comments
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
on 6 Oct 2023
0 votes
Hi Stéphane,
I understand that you are facing an error while generating code using a custom TLC file which contains the “LibMdlStartCustomCode” function.
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:
- https://www.mathworks.com/help/ecoder/ug/introduction-to-the-model-rtw-file.html
- https://www.mathworks.com/help/rtw/tlc/build-process.html
- https://www.mathworks.com/help/rtw/ug/customizing-system-target-files.html
Hope this helps and solves your error!
Categories
Find more on Simulink Coder 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!