Why am I getting the linking error "LINK : fatal error LNK1104: cannot open file xxx.obj" when trying to deploy a Simulink model that includes an S-Function onto a Real-Time target?

7 views (last 30 days)
It is sought to deploy a Simulink model that includes an S-Function onto a Real-Time target. The S-Function is generated from some custom code using the Legacy Code tool. The workflow that is followed is the following one,
1.) The S-Function is generated and compiled using the Legacy Code tool along with the following lines of code,
 
def = legacy_code('initialize'); def.SourceFiles = {'my_neuralnet.c', 'my_neuralnet.c'}; def.HeaderFiles = {'multiword_types.h', 'my_neuralnet.h', 'my_neuralnet_private.h', 'my_neuralnet_types.h', 'rtwtypes.h'}; def.OutputFcnSpec = 'double y1 = mypredict(double u1[7])'; def.SFunctionName = 'myModel_SFcn'; legacy_code('sfcn_cmex_generate', def); def.SourceFiles = {'my_neuralnet.c', 'my_neuralnet.c', 'my_neuralnet_data.c'}; legacy_code('sfcn_cmex_generate', def); legacy_code('compile', def); legacy_code('sfcn_tlc_generate',def);
2.) All header-, source- and obj-files along with the corresponding tlc-file that is generated from the call 'legacy_code('sfcn_tlc_generate',def)' together with the compiled S-Function are copied in the working directory where the model lies.
3.) The slrt-target is selected and then the Build button is pressed in Simulink to compile the model and download it on the target.
After step 3.) the following error message is obtained,
 
LINK : fatal error LNK1104: cannot open file 'my_neuralnet.obj' NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\link.EXE"' : return code '0x450' 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.
Why am I getting the linking error "LINK : fatal error LNK1104: cannot open file xxx.obj" when trying to deploy a Simulink model that includes an S-Function onto a Real-Time target?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 3 Dec 2021
Edited: MathWorks Support Team on 3 Dec 2021
Please note that when opting to deploy a Simulink model on a Real-Time target which contains an S-Function, then the S-Function should be recompiled on the slrt-target. To do so, one needs both the corresponding tlc-file for the Code Generation part and the so-called rtwmakecfg.m to customize the compilation process by means of the generated make-file by the Code Generator, which will instruct how the S-Function should be compiled and which dependencies it should resolve, i.e. which header-, source-, obj-files should be included and how these should be linked.
To generate such a make-file customization file, one needs to include the following line of code in the script that is used for the S-Function generation and compilation,
legacy_code('rtwmakecfg_generate', def);
The generated rtwmakecfg.m should be then placed under the working directory and it will be then used by the Code Generation for the corresponding customization of the generated make-file. This should already resolve the issue. For more information, please visit also the following documentation page,

More Answers (0)

Tags

No tags entered yet.

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!