Why do I receive errors when building a model which contains an S-function with MAT-file API in Simulink?
16 views (last 30 days)
Show older comments
MathWorks Support Team
on 27 Jun 2009
Edited: MathWorks Support Team
on 12 Sep 2022
I have a C-MEX S-function that I use to read data from a MAT-file. I use commands such as: matOpen, matGetVariable, in my C-code.
I also include the header file needed for using those functions, by using the command:
#include "mat.h"
When I build the model using Generic Real-Time target (grt.tl), I receive error messages during my build process.
For example:
C:\Apps\MATLAB\extern\include\matrix.h(144) : error C2371: 'mxArray' : redefinition; different basic types
C:\Apps\MATLAB\rtw\c\libsrc\rt_matrx.h(41) : see declaration of 'mxArray'
Or with the Simulink Real-Time target (slrealtime.tlc):
C:\ProgramData\MATLAB\SupportPackages\R2021b\toolbox\slrealtime\target\supportpackage\qnx710\\host\win64\x86_64\usr\bin\x86_64-pc-nto-qnx7.1.0-ld: sfun_wrapper.o: in function `sfun_Outputs_wrapper(double const*, double*, double*, double*, double*, double*, double*)':
D:/data/sfun_wrapper.cpp:70: undefined reference to `matOpen_800'
D:/data/sfun_wrapper.cpp:78: undefined reference to `matGetVariable_800'
D:/data/sfun_wrapper.cpp:90: undefined reference to `mxGetFieldNumber_800'
D:/data/sfun_wrapper.cpp:95: undefined reference to `mxGetField_800'
D:/data/sfun_wrapper.cpp:96: undefined reference to `mxGetPr_800'
D:/data/sfun_wrapper.cpp:97: undefined reference to `mxGetM_800'
D:/data/sfun_wrapper.cpp:165: undefined reference to `mxDestroyArray_800'
D:/data/sfun_wrapper.cpp:166: undefined reference to `matClose_800'
cc: C:/ProgramData/MATLAB/SupportPackages/R2021b/toolbox/slrealtime/target/supportpackage/qnx710//host/win64/x86_64/usr/bin/x86_64-pc-nto-qnx7.1.0-ld caught signal 1 sfun_mat.mk:235: recipe for target 'D:/data/MyModel_slrealtime_rtw/MyModel' failed
Accepted Answer
MathWorks Support Team
on 12 Sep 2022
Edited: MathWorks Support Team
on 12 Sep 2022
The ability to generate code from a model that has C MEX S-functions with MAT-file API functions is not available in Simulink Coder, Embedded Coder or Simulink Real-Time.
The MAT-file API relies on precompiled libraries that are only available for the host PC desktop platform (Windows, MacOS, Linux), and not for Embedded Targets.
The library source code is not available to users for re-compilation. There are no workarounds.
0 Comments
More Answers (0)
See Also
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!