How to solve mingw32-make.exe exited with code 2 e

2019-06-05 02:24发布

问题:

I've installed Qt Open source 4.8.3 library for Windows on Windows 8 Pro x64, Qt Creator 2.6.0 and MingW 4.4.0 manually. From Qt Creator I've setup kits and compilers. I opened the analog clock example comes along with Qt Creator and rebuild the project. The following error are emitted by the compiler.

Running steps for project analogclock...

Starting: "C:\Qt\4.8.3\bin\qmake.exe" C:\Qt\4.8.3\examples\widgets\analogclock\analogclock.pro -r -spec win32-g++

The process "C:\Qt\4.8.3\bin\qmake.exe" exited normally.

Starting: "C:\MingW\bin\mingw32-make.exe" 

C:/MingW/bin/mingw32-make -f Makefile.Release

mingw32-make[1]: Entering directory `C:/Qt/4.8.3/examples/widgets/analogclock-build-Desktop-Release'

g++ -c -O2 -Wall -Wextra -fno-exceptions -fno-rtti -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -DQT_NO_DYNAMIC_CAST -I"..\..\..\include\QtCore" -I"..\..\..\include\QtGui" -I"..\..\..\include" -I"..\..\..\include\ActiveQt" -I"release" -I"..\analogclock" -I"." -I"..\..\..\mkspecs\win32-g++" -o release\analogclock.o **..\analogclock\analogclock.cpp**

mingw32-make[1]: Leaving directory `C:/Qt/4.8.3/examples/widgets/analogclock-build-Desktop-Release'

mingw32-make[1]: *** [release/analogclock.o] Error 1

mingw32-make: *** [release] Error 2

The process "C:\MingW\bin\mingw32-make.exe" exited with code 2.

Error while building/deploying project analogclock (target: Desktop)

When executing step 'Make'

I've verified that C:/Qt/4.8.3/examples/widgets/analogclock/analogclock.cpp exists. Besides, this project comes with Qt installation and I didn't change anything.

Why is this error occurring and how can i fix it?

回答1:

It seems your installation of g++ is not clean, so the compiler cannot be launched (this is also what you've said in the comments). Try reinstall, and then you can try to build a hello world program to verify whether you can run g++. Also, please verify that your PATH variable is properly configured for mingw.



回答2:

Sounds like a bad mingw installation. Are there any other unix-ish things in your %PATH%, i.e. cygwin, or msys, perl, ruby, ... or other versions of mingw?



标签: c++ qt mingw