Generation of an S-function block in simulink by integrating legacy C-code through the legacy code tool

조회 수: 16 (최근 30일)
Hello,
I am trying to run this code also present in the mathworks website.
def = legacy_code('initialize'); def.SourceFiles = {'doubleIt.c'}; def.HeaderFiles = {'doubleIt.h'}; def.SFunctionName = 'legacy_wrapsfcn'; def.OutputFcnSpec = 'double y1 = doubleIt(double u1)'; def.SampleTime = [-1,0]; legacy_code('sfcn_cmex_generate', def); legacy_code('slblock_generate',def); legacy_code('compile', def);
The compiler throws up an error
### Start Compiling legacy_wrapsfcn mex('legacy_wrapsfcn.c', 'D:\Sunny_sfunction\doubleIt.c', '-ID:\Sunny_sfunction') legacy_wrapsfcn.c legacy_wrapsfcn.c(40) : fatal error C1083: Cannot open include file: 'simstruc.h': No such file or directory
C:\PROGRA~1\MATLAB\R2010B\BIN\MEX.PL: Error: Compile of 'legacy_wrapsfcn.c' failed.
??? Error using ==> mex at 208 Unable to complete successfully.
Error in ==> C:\Program Files\MATLAB\R2010b\toolbox\simulink\simulink\+legacycode\@LCT\compile.p>compile at 264
Error in ==> C:\Program Files\MATLAB\R2010b\toolbox\simulink\simulink\+legacycode\@LCT\legacyCodeImpl.p>legacyCodeImpl at 84
Error in ==> legacy_code at 87 [varargout{1:nargout}] = legacycode.LCT.legacyCodeImpl(action, varargin{1:end});
Error in ==> Sfunction_legacy1 at 31 legacy_code('compile', def);
The *.c and *.h files are in the same folder as the m-file. Could you please tell me where I am going wrong?

채택된 답변

Kaustubha Govind
Kaustubha Govind 2013년 10월 2일
Seems related to Bug# 661855. A patch is available on that page.

추가 답변 (1개)

Hariharan V
Hariharan V 2013년 10월 4일
Hello Kaustubha,
Thank you very much for your suggestion. I tried out the solution. It works.
Regards,
Hariharan

카테고리

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