Compile Model Reference with S-function & TLC

7 views (last 30 days)
I have a working S-function that I can mex for use in normal mode and a TLC file that successfully compiles and runs in accelerator mode. However, when trying to use the S-function in an accelerated reference model or a standalone model in rapid accelerator mode, compilation fails. The errors started with redefinition errors, mainly in "matrix.h" vs. "rt_matrix". If I force the use of strictly matrix.h, the compiler seems to not know of the "bool" type in the files "slMdlrefSfcnBridge.h" and "matrix.h", as it complains about syntax errors (like "missing ')' before identifier"). Has anyone encounter these errors before, and is there a workaround?

Accepted Answer

Thomas Satterly Satterly
Thomas Satterly Satterly on 25 Apr 2019
It turned out that the tool I was integrating, which was developed by someone else in Matlab and converted into C++ with the coder, included a "rtwtypes.h" file. Because the tool was developed in a newer version of Matlab (2016 vs 2013), it was the root of a lot of redefinition errors and unrecognized types. After replacing it with the 2013 version of "rtwtypes.h" and adding in defines for "TRUE" and "FALSE", everything finallaly compiled together and worked. Last problem is that the PWork vector seems to lose its functionality if external libraries are used during compilation, and stranger still, external library static variables only persist for a single major time step in Simulink, so there's no easy workarounds.

More Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products


Release

R2013b

Community Treasure Hunt

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

Start Hunting!