Why am I getting the error "The current model configuration differs from the model configuration used to generate the shared utility code folder" when building a model hierarchy?

4 views (last 30 days)
When I build my top-level model, I got the following error pointing to a referenced model or protected model <ReferencedModelName>.
Error building model '<ReferencedModelName>'. The current model configuration differs from the model configuration used to generate the shared utility code folder, '..\slprj\<target>\_sharedutils>'.
Click here to review parameter differences between '<ReferencedModelName>' and '..\slprj\<target>\_sharedutils'.
Suggested Actions:
Configure settings for '<ReferencedModelName>' so that there are no parameter differences.
~OR~
Remove '..\slprj\<target>\_sharedutils'.
~OR~
Consider generating code to a different folder structure.
How can I resolve this error?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 Oct 2025 at 0:00

What this issue means:

This error occurs due to inconsistencies in model parameters within a model hierarchy. During code generation, a "_sharedutils" folder is automatically created to store utility functions and shared code that are reused across different components. If models are configured with conflicting parameters, it can lead to errors during code generation. For details, refer to Set Configuration Parameters for Model Hierarchies and Set Configuration Parameters for Code Generation of Model Hierarchies

Try these workarounds:

Step 1: Delete and regenerate cache files and artifacts
As a first step, delete the following folders and files if they exist:
  • The 'slprj' folder, which includes the '_sharedutils' folder.
  • Any .slxc files.
  • The '<modelName>_<target>_rtw' code generation folder (e.g., 'MyModel_ert_rtw').
These files are typically located in the current directory. 
If your models include S-Functions, try regenerating any MEX files to ensure compatibility.
Step 2: Align configuration parameters between models
If the error message persists despite deleting all cache files and artifacts, inspect the parameter differences by following the comparison link provided in the error message and make any necessary adjustments.
To ensure consistency across models, it is recommended to use one shared configuration set to set each model's configuration parameters. This configuration set can be stored in a data dictionary (.sldd) for easier referencing and distribution. In the case of protected models, you can share your configuration set with the creator of the protected model so they can regenerate the protected model with matching settings -- or, you request the configuration set or a skeleton model from the creator to match you parent model settings. For more information, see Share a Configuration with Multiple Models.
NOTE: If certain configuration parameters cannot be manually changed, for example, the 'Hardware Device Type', which may be hidden, you can use the "set_param" function to set the parameter at the command line. For example, to set the 'Hardware Device Type' to 'Intel->x86/Pentium', you may use the following at the MATLAB Command Line: 
set_param('ProdHWDeviceType', 'Intel->x86/Pentium')
To modify the parameter within a Data Dictionary, refer to the code and how to Manage Configuration Set Stored in a Data Dictionary below: 
dd = Simulink.data.dictionary.open(<ReferencedModel_DataDictionary>.sldd')
ds = dd.getSection('Configurations')
ds.find('-class','Simulink.data.dictionary.Entry')
cs1=ds.getEntry('<ConfigurationName>')
v1=cs1.getValue()
set_param(v1, 'ProdHWDeviceType', 'Intel->x86/Pentium')
cs1.setValue(v1)
dd.saveChanges()

More Answers (0)

Categories

Find more on Deployment, Integration, and Supported Hardware in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!