legacy coder inlined S function in model ref fail accel mode
Show older comments
I have recently been working on integrating C++ code into Simulink platform with legacy coder. (MATLAB/Simulink 2016a)
The S function is to be placed in a model reference block to be ran under accelerator mode.
The model runs correctly on its own or referenced under normal mode. However, when being ran as referenced model under accelerator mode, error occurred with the following error message.
Simulink has generated its own wrapper file in the cache folder, and the generated wrapper is unable to find the header of the source file from the cache location.
mySFun_wrapper.cpp(9) : fatal error C1083: Cannot open include file: 'mySFun.h': No such file or directory
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\amd64\cl.EXE"' : return code '0x2'
Stop.
The make command returned an error of 2
'An_error_occurred_during_the_call_to_make' is not recognized as an internal or external command,
operable program or batch file.
It has been verified that the source files are on MATLAB path.
Configuration Parameter panel has been configured such:
- mySfun.cpp, Sfun.h has been included to "Simulation Target" panel of the model reference
- Code Generation page is configured to use System target file "ert.tlc"; Language of "C++"; SDK v7.1
ltc_spec has been configured for accelerator mode, and tlc file has been generated as shown below;
def = legacy_code('initialize');
def.SFunctionName = 'mySfun';
def.SourceFiles = {'mySfun.cpp'}; // connect to source file
def.HeaderFiles = {'mySfun.h'};
def.IncPaths = {'.','./lib'};
def.SrcPaths = {'.','./lib'};
def.Options.language = 'C++';
def.Options.useTlcWithAccel = true; // configure for Legacy Coder
def.Options.supportsMultipleExecInstances = true;
def.OutputFcnSpec = ['CustomType y1 = mySfun(CustomType u1)']; // IO configuration
% legacy_code('generate_for_sim', def); // I have also tried this, but nothing changed
legacy_code('sfcn_tlc_generate', def);
legacy_code('sfcn_cmex_generate', def);
legacy_code('compile', def);
legacy_code('slblock_generate', def); // this generated block is dropped into model reference
ltc file is placed under same directory of the source file.
Has anyone experienced similar issue before? Is there an existing solution?
Thank you.
1 Comment
Ophelia Chung
on 11 Oct 2017
Answers (0)
Categories
Find more on Simulink Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!