필터 지우기
필터 지우기

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

조회 수: 21 (최근 30일)
TyMcMe
TyMcMe 2020년 7월 31일
답변: Nipun Katyal 2020년 8월 10일
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.

답변 (1개)

Nipun Katyal
Nipun Katyal 2020년 8월 10일
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')

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB Compiler SDK에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by