MATLAB: Does the model, containing a Library Stateflow chart, fail to compile if the library link is active

compilationdirectoriesfailsfunctionincludesimulinkstateflowunresolved

I have a Simulink library that contains a subsystem with a Stateflow chart. The Stateflow chart is using the C language, and makes a call to an external function. This library subsystem is placed in a parent model. The parent model has the configuration Simulation Target > Header File, Include Directories, and Libraries configured to provide that function that is being called by Stateflow. When the library link is active, the Update Diagram fails, with the error message "unresolved function f32min". If I break the library link, Update Diagram is successful, and I can simulate my model.
How do I fix this?

Best Answer

The library chart is set to override custom code settings from the main model. That is the root cause of the issue.
To fix this: 1) Open the library model and unlock the diagram
2) Open the Stateflow chart.
3) View > Library Custom Code Settings > Simulation Target
4) Clear the "Use local custom code settings (do not inherit from main model)" checkbox
5) Click Ok
6) View > Library Custom Code Settings > Code Generation
7) Clear the "Use local custom code settings (do not inherit from main model)" checkbox
8) Click Ok
9) Save the library model Now the error should go away even when the library is still linked.