- In the library, go to the reusable library subsystem. Right-click on the reusable subsystem, and select C/C++ Function Interfaces > Create Function Interface.
- In the Create Function Interface dialog, select Specify library block instance to create function interface. Browse and select the Simulink model with the subsystem instance. Note that if you want to reuse the existing Function Interface name, you would need to delete the existing function interface.
- Delete the existing source code in the slprj folder, and re-build the library and component.
- Alternatively, right-click on the subsystem, and select "Configure Function Interface". Select Regenerate Using Instance and click Regenerate to override the existing interface.
Why am I getting a build error regarding library code reuse when using Simulink Coder in MATLAB R2022b?
7 views (last 30 days)
Show older comments
MathWorks Support Team
on 18 Jan 2024
Edited: MathWorks Support Team
on 22 Feb 2024
I am using MATLAB R2022b to run a script that generates code using Simulink Coder. However, I get an error that starts with:
Error using tlc_c
Subsystem 'Model/Subsystem/Block_name' is linked to a library block that specifies
a token '$R' in its function name. Using this token in the function name is supported only
if the model subsystem reuses library code. This subsystem does not reuse library code.
How do I resolve this error?
Accepted Answer
MathWorks Support Team
on 14 Feb 2024
Based on the error message, it appears that root cause of the issue is that the checksum of the instance of the library subsystem in the model does not match with the checksum of the Function Interface defined for the library. For Embedded Coder to reuse the generated library code, the checksum of the library subsystem instance in the model should match that of the exported function interface model for the library. See the documentation page "Library-based Code Generation for Reusable Library Subsystems" to understand how to export a function interface as an independent model:
To resolve this issue, you can create a new Function Interface based on the instance of the library subsystem in the model and generate code by following the steps below:
0 Comments
More Answers (0)
See Also
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!