DLL from Simulink model with MEX - proto function

3 visualizaciones (últimos 30 días)
Eginio
Eginio el 3 de Ag. de 2017
Editada: Nick Sarnie el 15 de Ag. de 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 comentarios
Michaël ROBARD
Michaël ROBARD el 25 de Abr. de 2019
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 el 11 de Ag. de 2019
Did you resolve somehow your problem? I have the same one...
Many thanks

Iniciar sesión para comentar.

Respuestas (1)

Nick Sarnie
Nick Sarnie el 15 de Ag. de 2019
Editada: Nick Sarnie el 15 de Ag. de 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.
Thanks,
Nick

Categorías

Más información sobre Simulink Coder en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by