Why do I receive errors when building a model which contains an S-function with MAT-file API in Simulink?

16 次查看(过去 30 天)
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

采纳的回答

MathWorks Support Team
编辑:MathWorks Support Team 2022-9-12
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 个)

类别

Help CenterFile Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by