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?