Warning: In rtwmakecfg.m, "bdroot" are excluded from packaging for the MATLAB Runtime environment

9 次查看(过去 30 天)
When compiling my simulink model to an .exe file with mcc, I noticed that if it contains an s-function block, I get this error:
Warning: In "<path-to-rtwmakecfg.m>", "bdroot" are excluded from packaging for the MATLAB Runtime environment according to the MATLAB Compiler license. Either remove the file or function from your code, or use the MATLAB function "isdeployed" to ensure the function is not invoked in the deployed component.
Mainly, I would like to know if this is a problem and if there's a way to remove the warning.
Another warning message I get during compilation which may be related:
Warning: The S-function '<sfunction-name>' has the option SS_OPTION_WORKS_WITH_CODE_REUSE set but it does not have a '<sfunction-name>.tlc' file. The system that it lives in will not be reused.
I'm not sure if it's related, because I'm not using simulink coder and my understanding is TLC files are only relevant to coder. Also I made sure that the 'enable code reuse' checkbox was not checked off in the s-function builder block and recompiled the s-func a few times, but the warning still hasn't gone away.
  1 个评论
Josh
Josh 2024-1-11
This also led me to some questions/discoveries about the s-function builder and generated mex files which could be helpful to document:
  1. The s-function builder seems to generate its files to the current matlab working folder, which means that any included library files using relative paths need to take this into account if you change the matlab working folder. This also means that if you want your matlab project's startup folder to be the root directory, you will end up having a bunch of mexw64, cpp files and whatnot directly in the root which is kind of messy.
  2. If you compile the same s-function into a few different locations, it looks like Simulink will update the project's dependencies to use the most recently generated mexw64 file, so you can delete the older files. But also it doesn't look like there's a way to tell Simulink to use an older mex file, so if you wanted to revert to a previous version you'll have to undo your changes to the s-function builder and recompile it.
  3. What is rtwmakecfg.m? Why does Simulink Compiler need this? It seems like even my top-level .slx file depends on the file.
  4. It seems to me that Simulink Compiler needs not only the mexw64 files, but also the cpp files generated by the s-function builder? I thought the point of generating the mex files was that I would only need those and nothing else, for the s-function to work in a simulink model. Or does Simulink only need the mex files but Simulink Compiler needs more?

请先登录,再进行评论。

回答(1 个)

Hassaan
Hassaan 2024-1-11
Warning 1: Use of bdroot in rtwmakecfg.m
The first warning is about the use of the bdroot function in the rtwmakecfg.m file, which is not supported when packaging for the MATLAB Runtime environment. Here are some steps you can take to resolve this warning:
  • Check for bdroot Usage: Open the rtwmakecfg.m file and check if bdroot is being used. If it is, you'll need to modify the code to ensure it's not called when deployed.
  • Use isdeployed: Wrap any calls to bdroot with an isdeployed check. This MATLAB function returns true when the code is running in the compiled application and false otherwise. Here’s how you might use it:
if ~isdeployed
% Your code that uses bdroot
end
  • Remove or Modify the File: If bdroot is not essential for the compilation of your model, consider removing the usage or the rtwmakecfg.m file altogether if it's not needed.
Warning 2: Missing .tlc file for S-Function
The second warning is related to the S-function block indicating that it's set to work with code reuse but doesn't have an associated .tlc (Target Language Compiler) file. This can be problematic if you’re not using Simulink Coder, but here are some steps to address it:
  • Unset SS_OPTION_WORKS_WITH_CODE_REUSE: If you have access to the S-function's source code, you can modify it to unset the SS_OPTION_WORKS_WITH_CODE_REUSE option. This is done within the mdlInitializeSizes function in the S-function code. You would look for a line that sets this option and remove it or comment it out.
  • Check S-Function Builder Settings: Double-check the settings in the S-Function Builder GUI to ensure that code reuse is indeed turned off.
  • Regenerate S-Function: After making changes to the S-function or its settings, regenerate the S-function to make sure the changes take effect.
  • Contact MathWorks Support: If the warning persists despite the above steps, it may be a good idea to contact MathWorks technical support for guidance specific to your situation.
It's important to note that while these are warnings and may not prevent the generation of the .exe file, they can indicate potential issues that might affect the execution of the compiled application. If the warnings can be safely ignored and the compiled application works as intended, they may not be a problem. However, it's always best to resolve warnings to ensure full compatibility and prevent any unforeseen issues during runtime.
---------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering
Feel free to contact me.

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by