C++ 步骤“make”中的Qt Creator编译错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20355562/
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
Qt Creator Compiling Error at step 'make'
提问by SplatFace Development
I just started using Qt Creator for creating C++ GUI programs. I just downloaded it and installed it, but the compiling process is throwing me errors. When I try to compile my project (very simple, just a QLabel on the screen...it's my first project) it comes up with the error:
我刚开始使用 Qt Creator 创建 C++ GUI 程序。我刚刚下载并安装了它,但是编译过程给我带来了错误。当我尝试编译我的项目(非常简单,屏幕上只有一个 QLabel ......这是我的第一个项目)时,它出现了错误:
qtcreator_ctrlc_stub: Command line failed: C:\Users\andrew\Dropbox\Programming\C++\build-
FirstGUIApp-Desktop_Qt_5_1_1_MSVC2012_32bit-Debug\Makefile 10:04:35: The process "C:\Users\andrew\Dropbox\Programming\C++\build-FirstGUIApp-Desktop_Qt_5_1_1_MSVC2012_32bit-Debug\Makefile" exited with code -1. Error while building/deploying project FirstGUIApp (kit: Desktop Qt 5.1.1 MSVC2012 32bit) When executing step 'Make'
qtcreator_ctrlc_stub:命令行失败:C:\Users\andrew\Dropbox\Programming\C++\
build-FirstGUIApp-Desktop_Qt_5_1_1_MSVC2012_32bit-Debug\Makefile 10:04:35:进程“C:\Users\andrew\Dropbox\C++\Programming build-FirstGUIApp-Desktop_Qt_5_1_1_MSVC2012_32bit-Debug\Makefile”以代码 -1 退出。构建/部署项目 FirstGUIApp 时出错(工具包:Desktop Qt 5.1.1 MSVC2012 32bit)执行步骤“Make”时
I hunted around for an answer hereand hereand a couple other places but I'm just confused about the whole thing. I have a couple of ideas of my own but I don't know how to try my ideas. Here are some of my ideas:
我在这里和这里以及其他几个地方四处寻找答案,但我只是对整件事感到困惑。我有一些自己的想法,但我不知道如何尝试我的想法。以下是我的一些想法:
1) MinGW isn't in the path or isn't installed
1) MinGW 不在路径中或未安装
But, if it isn't in the path, how do I put it in? Where is it? I have Code Blocks installed which has MinGW installed, so could I maybe use it from there?
但是,如果它不在路径中,我如何将其放入?它在哪里?我安装了安装了 MinGW 的代码块,所以我可以从那里使用它吗?
2) the make file is messed up somehow
2)make文件不知何故搞砸了
Again, what could be wrong and how could I fix it?
再说一次,可能是什么问题,我该如何解决?
3) Qt Creator isn't installed correctly.
3) Qt Creator 安装不正确。
Obviously, re-install it, but I want to make sure all other options are tried before, because it took me a very long time to download.
显然,重新安装它,但我想确保之前尝试过所有其他选项,因为我花了很长时间下载。
I apologize if I'm sounding noobish or it's a stupid question, but I really am confused with all of this. Please be patient with me and try to explain things well and thoroughly. I'm using Windows 8.1 and downloaded the offline installer. Thanks in advance.
如果我听起来很笨拙或者这是一个愚蠢的问题,我深表歉意,但我真的对这一切感到困惑。请耐心等待,尽量把事情解释清楚。我使用的是 Windows 8.1 并下载了离线安装程序。提前致谢。
UPDATE
更新
这是我的 Qt 的截图,我怎么知道它是 Visual Studio 还是 minGW 版本?

UPDATE
更新
这是我在 CodeBlocks 中的 MinGW 文件夹。这是编译器所在的文件夹还是别的什么?
回答by zero
For your ideas:
1: if you downloaded from qtproject with binary. then qt and qt creator should be installed under the C:\Qt\Qt5.1.1 then corresponding minGW should be stay in C:\Qt\Qt5.1.1\Tools\mingw48_32\bin\gcc.exe
this is the directory you need. Remember, QtCreator needs two tools to make sure your project and compile and run, qmake and compiler.
Qmake is tool help you translate .pro file into makefile,
compiler (gcc) minGW use gcc to run the makefile, compile your code to binary.
对于您的想法: 1:如果您从 qtproject 下载二进制文件。那么qt和qt creator应该安装在C:\Qt\Qt5.1.1下然后对应的minGW应该就在C:\Qt\Qt5.1.1\Tools\mingw48_32\bin\gcc.exe
你需要的目录下。请记住,QtCreator 需要两个工具来确保您的项目和编译运行,qmake 和编译器。Qmake 是帮助您将 .pro 文件转换为 makefile 的工具,编译器 (gcc) minGW 使用 gcc 运行 makefile,将您的代码编译为二进制文件。
where to figure out tools you are using are correct?
---> qtcreator --> Tools -> Build&Run -> Kits
in here You should be able find different kits, of course you maybe have only one.
在哪里确定您使用的工具是正确的?--->qtcreator --> Tools -> Build&Run -> Kits
在这里您应该可以找到不同的套件,当然您可能只有一个。
Select one, Double check the Qt Version and Compiler is the one you wish to use.
click Manage next to compiler, Every compiler in the Auto-detect should be ok to use.
If you don't see anyone, add one, click Add, MinGW, put C:\Qt\Qt5.1.1\Tools\mingw48_32\bin\gcc.exe
like into path. ABI should auto-set depends on your environment.
选择一个,仔细检查 Qt 版本,编译器是您要使用的版本。单击编译器旁边的管理,自动检测中的每个编译器都应该可以使用。如果你没有看到任何人,添加一个,点击添加,MinGW,将C:\Qt\Qt5.1.1\Tools\mingw48_32\bin\gcc.exe
like放入路径。ABI 应该自动设置取决于您的环境。
Answer to your second question, what's wrong with your makefile, no one knows, you should check your .pro, usually makefile are generated by qmake xx.pro. Double check your .pro file and re-run qmake will solve the problem.
回答你的第二个问题,你的makefile有什么问题,没人知道,你应该检查你的.pro,通常makefile是由qmake xx.pro生成的。仔细检查您的 .pro 文件并重新运行 qmake 将解决问题。
回答by Amir Hossein
Terminal:(in Linux) sudo apt-get install build-essential cmake libqt4-dev
终端:(在 Linux 中)sudo apt-get install build-essential cmake libqt4-dev
i'm sorry i dont know why this code works,but i have the same problem in linux and this code worked.
对不起,我不知道为什么这段代码有效,但我在 linux 中遇到了同样的问题,这段代码有效。
回答by ratchet freak
in tools->options->build&run check if minGW is actually there in the compiler and kit list
in the project tab (on the left hand side) you can set the environment for the build click the PATH value and add the path to minGW to it (you may need to add a lib and include var so the standard library gets added)
re run qmake from the build menu
double check you have the correct version it looks like you have the visual studio Qt not the minGW version,
在工具->选项->构建和运行中检查编译器和套件列表中是否确实存在minGW
在项目选项卡(在左侧)中,您可以设置构建环境,单击 PATH 值并将 minGW 的路径添加到其中(您可能需要添加一个 lib 并包含 var 以便添加标准库)
从构建菜单重新运行 qmake
仔细检查您是否拥有正确的版本,看起来您拥有的是 Visual Studio Qt 而不是 minGW 版本,