MATLAB Answers

DLL from Simulink model with MEX - proto function

조회 수: 9(최근 30일)
Eginio 3 Aug 2017
편집: Nick Sarnie 15 Aug 2019
Recently I was trying to generate a DLL for Matlab GUI from Simulink model. In this Simulink model I have a S-Function that is using mexw64 file. This S-Function is a closed code. I have only an obj file and libraries to build a mex file. The mex in Simulink simulation is working well.
I was able to generate a DLL by adding the obj file to Code Generation > Custom Code > Source files and all lib files to Code Generation > Custom Code > Include directories. The system target in Simulink is: ert_shrlib.tlc.
I result I have a DLL, so I was trying to generate a proto function:
coder.loadlibrary('simtest_170802_win64.dll', 'simtest_170802_ert_shrlib_rtw/simtest_170802.h','mfilename','mHeader')
Unfortunately I got the error:
Error using loadlibrary
Failed to preprocess the input file.
Output from preprocessor is:simtest_170802.h
c:\workspace\20170802\simtest_170802_ert_shrlib_rtw\simstruc.h(292) : fatal error C1189: #error :
Unrecognized use.
Error in coder.loadlibrary (line 39)
[varargout{1:nargout}] = loadlibrary(library, wrapperHeader, varargin{:});
If I try to use the header file instead to use the proto function I get the same error. Do you have some ideas?
  댓글 수: 3
Panagiotis Bountouris
Panagiotis Bountouris 11 Aug 2019
Did you resolve somehow your problem? I have the same one...
Many thanks

댓글을 달려면 로그인하십시오.


Nick Sarnie
Nick Sarnie 15 Aug 2019
편집: Nick Sarnie 15 Aug 2019
Hi all,
This workflow is only supported if you have an inlined S-Function. That means there is a .tlc file for the S-Function.
If you have an inlined S-Function but this error still occurs, please contact Technical Support.

Community Treasure Hunt

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

Start Hunting!

Translated by