Clear Filters
Clear Filters

import Simulink code into code composer studio

6 views (last 30 days)
Gaston Melo
Gaston Melo on 14 May 2020
Answered: Vidip on 7 Jun 2024
I to all, I have a simulink model with an S-Function Builder (include header files and some code). I was able to generate the C dode using Simulink coder (it generate the wrapper.c - tlc - c files).
What I want now is to import this file into CCS but when I tried to compile using CCS i got the error shown bellow. How can I solve this?:
#error directive: Must define one of RT, NRT, MATLAB_MEX_FILE, SL_INTERNAL, or FIPXT_SHARED_MODULE .ccsproject /Matlab_simulink_project line 316, external location: /home/gaston/.local/MATLAB/R2020a/simulink/include/simstruc_compcond.h C/C++ Problem

Answers (1)

Vidip
Vidip on 7 Jun 2024
The error message you're encountering, 'Must define one of RT, NRT, MATLAB_MEX_FILE, SL_INTERNAL, or FIPXT_SHARED_MODULE', typically occurs during the compilation of MATLAB MEX files or Simulink models that interface with C/C++ code.
This issue has several possible root causes. Here are some troubleshooting steps you can try to find the root cause of the issue:
  1. If an S-Function has TLC inlining files, then the "S-function modules" parameter in the S-Function block should be left blank. Setting the "S-function modules" parameter to the name of MEX source code for the S-Function introduces non-inline MEX source code into the build process. This results in an error message because the build process recognizes that the S-Functions were inline with TLC, so it doesn't include the -DRT on the compile line.
  2. If the C/C++ MEX S-Function file contain the ‘#define MATLAB_MEX_FILE’ preprocessor directive, then this directive should be removed from the C/C++ MEX S-Function file. The definition will automatically be included in the compiler arguments when the MEX file is built. For information on creating a C MEX S-Function, refer to the following documentation page: https://in.mathworks.com/help/simulink/sfg/example-of-a-basic-c-mex-s-function.html
  3. If you are attempting to build the code in an external IDE and receiving these error messages, then try to ensure the required defines are set properly. You can find the required defines in the text file in your model's code generation directory. Check to see if any compiler flags (for example, RT or USE_RTMODEL) should be added to the external IDE and verify that the following folder is included by the external IDE: <matlabroot>\extern\include

Categories

Find more on Event Functions in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!