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 CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by