How to solve 'Make command returned an error of 2'

40 ビュー (過去 30 日間)
Marcel S
Marcel S 2022 年 6 月 15 日
回答済み: Pramil 2024 年 9 月 10 日
Hey everyone,
When generating code for my Simulink model I receive the following error:
### Generating code into build folder: C:\Repos\VEPF\vepf-ex-vhil\cgmodel\vhil_main_ert_rtw
### Invoking Target Language Compiler on vhil_main.rtw
### Using System Target File: C:\Tools\Matlab\R2019b\rtw\c\ert\ert.tlc
### Loading TLC function libraries
### Initial pass through model to cache user defined code
### Caching model source code
### Writing header file vhil_main_types.h
### Writing source file vhil_main.c
### Writing header file vhil_main_private.h
.
### Writing header file vhil_main.h
### Writing header file rtwtypes.h
### Writing source file ert_main.c
### TLC code generation complete.
### Using toolchain: MinGW64 | gmake (64-bit Windows)
### 'C:\Repos\VEPF\vepf-ex-vhil\cgmodel\vhil_main_ert_rtw\vhil_main.mk' is up to date
### Building 'vhil_main': "C:\Tools\Matlab\R2019b\bin\win64\gmake" -f vhil_main.mk all
### Creating HTML report file vhil_main_codegen_rpt.html
### Build procedure for model: 'vhil_main' aborted due to an error.
C:\Repos\VEPF\vepf-ex-vhil\cgmodel\vhil_main_ert_rtw>cd .
C:\Repos\VEPF\vepf-ex-vhil\cgmodel\vhil_main_ert_rtw>if "" == "" ("C:\Tools\Matlab\R2019b\bin\win64\gmake" -f vhil_main.mk all ) else ("C:\Tools\Matlab\R2019b\bin\win64\gmake" -f vhil_main.mk )
"C:\Tools\MINGW_63\mingw64\bin/gcc" -c -fwrapv -m64 -O0 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTERMFCN=1 -DONESTEPFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DTID01EQ=0 -DMODEL=vhil_main -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 @vhil_main_comp.rsp -o "vhil_main.obj" "C:/Repos/VEPF/vepf-ex-vhil/cgmodel/vhil_main_ert_rtw/vhil_main.c"
gmake: *** [vhil_main.obj] Error 1
C:\Repos\VEPF\vepf-ex-vhil\cgmodel\vhil_main_ert_rtw>echo The make command returned an error of 2
The make command returned an error of 2
C:\Repos\VEPF\vepf-ex-vhil\cgmodel\vhil_main_ert_rtw>exit 1
Error(s) encountered while building "vhil_main":
### Failed to generate all binary outputs.
How can I generally investigate problems like these? As far as I see there are no clear statements why the make command failes. The only thing which looks a little bit strange is the path to gcc 'C:\Tools\MINGW_63\mingw64\bin/gcc' where a slash is used at the end while the rest is written with backslashes. Anyhow the environment variables should be fine. Also I checked that I don't have any whitespaces in any installation paths which could cause problems.
The following CompilerConfiguration is active:
CompilerConfiguration with properties:
Name: 'MinGW64 Compiler (C)'
Manufacturer: 'GNU'
Language: 'C'
Version: '6.3.0'
Location: 'C:\Tools\MINGW_63\mingw64'
ShortName: 'mingw64'
Priority: 'E'
Details: [1×1 mex.CompilerConfigurationDetails]
LinkerName: 'C:\Tools\MINGW_63\mingw64\bin\gcc'
LinkerVersion: ''
MexOpt: 'C:\Tools\Matlab\R2019b\bin\win64\mexopts\mingw64.xml'
CompilerConfigurationDetails with properties:
CompilerExecutable: 'C:\Tools\MINGW_63\mingw64\bin\gcc'
CompilerFlags: '-fexceptions -fno-omit-frame-pointer'
OptimizationFlags: '-O2 -fwrapv -DNDEBUG'
DebugFlags: '-g'
LinkerExecutable: 'C:\Tools\MINGW_63\mingw64\bin\gcc'
LinkerFlags: '-m64 -Wl,--no-undefined'
LinkerOptimizationFlags: '-s'
LinkerDebugFlags: '-g'
SetEnv: 'set COMPILER=C:\Tools\MINGW_63\mingw64\bin\gcc↵ set CXXCOMPILER=C:\Tools\MINGW_63\mingw64\bin\g++↵ set COMPFLAGS=-c -fexceptions -fno-omit-frame-pointer -m64 -DMATLAB_MEX_FILE -DMATLAB_MEX_FILE ↵ set CXXCOMPFLAGS=-c -fexceptions -fno-omit-frame-pointer -std=c++11 -m64 -DMATLAB_MEX_FILE -DMATLAB_MEX_FILE ↵ set OPTIMFLAGS=-O2 -fwrapv -DNDEBUG↵ set DEBUGFLAGS=-g↵ set LINKER=C:\Tools\MINGW_63\mingw64\bin\gcc↵ set CXXLINKER=C:\Tools\MINGW_63\mingw64\bin\g++↵ set LINKFLAGS=-m64 -Wl,--no-undefined -shared -static -L"C:\Tools\Matlab\R2019b\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -lm -llibmwlapack -llibmwblas -Wl,"C:\Tools\Matlab\R2019b/extern/lib/win64/mingw64/mexFunction.def"↵ set LINKDEBUGFLAGS=-g↵ set NAME_OUTPUT=-o "%OUTDIR%%MEX_NAME%%MEX_EXT%"↵set PATH=C:\Tools\MINGW_63\mingw64\bin;C:\Tools\Matlab\R2019b\extern\include\win64;C:\Tools\Matlab\R2019b\extern\include;C:\Tools\Matlab\R2019b\simulink\include;C:\Tools\Matlab\R2019b\lib\win64;%MATLAB_BIN%;%PATH%↵set INCLUDE=C:\Tools\MINGW_63\mingw64\include;;%INCLUDE%↵set LIB=C:\Tools\MINGW_63\mingw64\lib;;%LIB%↵set LIBPATH=C:\Tools\Matlab\R2019b\extern\lib\win64;%LIBPATH%↵'
CommandLineShell: 'set MINGW_ROOT_PATH=C:\Tools\MINGW_63\mingw64'
CommandLineShellArg: ''
  2 件のコメント
Chetan Pawar
Chetan Pawar 2022 年 12 月 6 日
Facing the same issue. Any probable solutions?
Antony Smith
Antony Smith 2023 年 5 月 10 日
Did anyone manage to solve this error?
"The make command returned an error of 2 "

サインインしてコメントする。

回答 (1 件)

Pramil
Pramil 2024 年 9 月 10 日
Hey Marcel,
I have faced a similar issue and there was no whitespace in my folder path as well.
What worked for me was moving the SLX files to a different folder location. This issue could have been due to the length of the folder path. Once I shortened the path, the problem was resolved.
Hopefully it might resolve your issue as well.

カテゴリ

Help Center および File ExchangeSimulink についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by