Azzera filtri
Azzera filtri

How do I get rid of "gmake: *** [main.obj] Error 1" when using MATLAB Coder?

21 visualizzazioni (ultimi 30 giorni)
I am following the "Generating Standalone C/C++ Executables from MATLAB Code" found here: https://www.mathworks.com/help/coder/ug/standalone-c-c-executables-from-matlab-code.html
I execute the following commands in the Command Window:
cfg = coder.config('exe');
cfg.CustomSource = 'main.c';
cfg.CustomInclude = 'c:\myfiles';
codegen -config cfg coderand
Upon execution I get the following error message:
------------------------------------------------------------------------
"C:\PROGRA~3\MATLAB\SUPPOR~1\R2020a\3P778C~1.INS\MINGW_~1.INS\bin/gcc" -c -fwrapv -m64 -O3 -fno-loop-optimize -fno-aggressive-loop-optimizations -D__USE_MINGW_ANSI_STDIO=1 -DMODEL=coderand -DMODEL=coderand @coderand_rtw_comp.rsp -o "main.obj" "C:/myfiles/main.c"
gmake: *** [main.obj] Error 1
The make command returned an error of 2
Error(s) encountered while building "coderand":
### Failed to generate all binary outputs.
------------------------------------------------------------------------
??? Build error: C compiler produced errors. See the Build Log for further details.
More information
Code generation failed: View Error Report
Error using codegen
Any help on this issue would be greatly appreciated.

Risposte (1)

Nipun Katyal
Nipun Katyal il 10 Ago 2020
After the generation of code you will find the main function in “/codegen/lib/coderand/examples” folder. Create another folder “myfiles” in “/codegen/lib/coderand/” directory and copy the “main.c “ and “main.h” file to those directory. Apply the modifications mentioned in the documentation. Go to the directory containing the “coderand.m” function and execute the following commands.
cfg = coder.config('exe');
cfg.CustomSource = '.\codegen\lib\coderand\myfiles\main.c';
cfg.CustomInclude = '.\codegen\lib\coderand\myfiles';
codegen -config cfg coderand
The executable will be generated in the same directory, which can be executed using the system command.
system('coderand')

Categorie

Scopri di più su Get Started with MATLAB Compiler SDK in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by