C++ 如何解决 mingw32-make.exe 以代码 2 错误退出?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13442233/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to solve mingw32-make.exe exited with code 2 error?
提问by Donotalo
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.
我已经安装了Qt Open source 4.8.3
库的Windows上Windows 8 Pro x64
,Qt Creator 2.6.0
和MingW 4.4.0
手动。我从 Qt Creator 安装了工具包和编译器。我打开了 Qt Creator 附带的模拟时钟示例并重建了项目。编译器发出以下错误。
Running steps for project analogclock...
Starting: "C:\Qt.8.3\bin\qmake.exe" C:\Qt.8.3\examples\widgets\analogclock\analogclock.pro -r -spec win32-g++
The process "C:\Qt.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.cppexists. Besides, this project comes with Qt installation and I didn't change anything.
我已经验证C:/Qt/4.8.3/examples/widgets/analogclock/analogclock.cpp存在。此外,这个项目带有 Qt 安装,我没有改变任何东西。
Why is this error occurring and how can i fix it?
为什么会发生此错误,我该如何解决?
回答by Synxis
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.
看来您的g++安装不干净,因此无法启动编译器(这也是您在评论中所说的)。尝试重新安装,然后可以尝试构建一个hello world程序来验证是否可以运行g++。另外,请验证您的 PATH 变量是否已为 mingw 正确配置。
回答by aviit
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?
听起来像一个糟糕的 mingw 安装。您的 %PATH% 中是否还有其他 unix-ish 内容,即 cygwin、msys、perl、ruby 或其他版本的 mingw?