DLL from Simulink model with MEX - proto function

1 回表示 (過去 30 日間)
Eginio
Eginio 2017 年 8 月 3 日
編集済み: Nick Sarnie 2019 年 8 月 15 日
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 件のコメント
Michaël ROBARD
Michaël ROBARD 2019 年 4 月 25 日
Hello everyone,
I have the same kind of problem. I searched several days and I didn't find the solution.
I compiled a simulink model with MinGW 64bits and ert_shrlib.tlc as the target. The compilation worked well : no errors, generate the folder model_ert_shrlib, generate model.dll. After that when I tried to generate the mHeader file with :
coder.loadlibrary('model_win64.dll', 'model.h','mfilename','mHeader')
I receive these errors :
Error using loadlibrary
Failed to preprocess the input file.
Output from preprocessor is:In file included from
D:/Users/model.h:26:0,
from
D:\Users\model.h:7:
D:/Users/simstruc.h:299:3:
error: #error Unrecognized use.
# error Unrecognized use.
^
D:/Users/simstruc.h:371:3:
error: #error Must define one of RT, NRT, MATLAB_MEX_FILE,
SL_INTERNAL, or FIPXT_SHARED_MODULE
# error Must define one of RT, NRT, MATLAB_MEX_FILE, SL_INTERNAL,
or FIPXT_SHARED_MODULE
^
D:/Users/simstruc.h:494:3:
error: #error Unhandled case
# error Unhandled case
^
Error in coder.loadlibrary (line 39)
[varargout{1:nargout}] = loadlibrary(library, wrapperHeader,
varargin{:});
Does someone has answer element ? Or a method in order to debug theses errors ?
Thank you very much !
Panagiotis Bountouris
Panagiotis Bountouris 2019 年 8 月 11 日
Did you resolve somehow your problem? I have the same one...
Many thanks

サインインしてコメントする。

回答 (1 件)

Nick Sarnie
Nick Sarnie 2019 年 8 月 15 日
編集済み: Nick Sarnie 2019 年 8 月 15 日
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.
Thanks,
Nick

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by