无法在qtcreator中编译Qt项目

Unable to Compile a Qt project in qtcreator

本文关键字:编译 Qt 项目 qtcreator      更新时间:2023-10-16

我无法编译一个简单的Qt项目(与主窗口的一个例子)。我通过命令shell和QtCreator尝试了它。首先,qmake应该使用命令规则创建makefile,以便将我的UI简单地转换为。h。

Qt Creator在控制台上显示以下警告/错误消息。

09:06:30: Running steps for project untitled...
09:06:30: Starting: "D:QTqt-everywhere-opensource-src-5.6.0qtbasebinqmake.exe" C:workspace_llb_27-05-2016untitleduntitled.pro -r -spec win32-g++
09:06:32: The process "D:QTqt-everywhere-opensource-src-5.6.0qtbasebinqmake.exe" exited normally.
09:06:32: Starting: "C:mingwmingwx64_481r0-sjlj-rev2binmingw32-make.exe" 
C:/mingw/mingwx64_481r0-sjlj-rev2/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'C:/build_untitled_Qt_5_6_0_Built_by_mingwx64_481r0_sjlj_rev2_Debug'
/C/build_untitled_Qt_5_6_0_Built_by_mingwx64_481r0_sjlj_rev2_Debug/uic_wrapper.sh ../workspace_llb_27-05-2016/untitled/mainwindow.ui -o ui_mainwindow.h
Makefile.Debug:318: recipe for target 'ui_mainwindow.h' failed
process_begin: CreateProcess(NULL, /C/build_untitled_Qt_5_6_0_Built_by_mingwx64_481r0_sjlj_rev2_Debug/uic_wrapper.sh ../workspace_llb_27-05-2016/untitled/mainwindow.ui -o ui_mainwindow.h, ...) failed.
make (e=2): Le fichier spécifié est introuvable.
mingw32-make[1]: *** [ui_mainwindow.h] Error 2
mingw32-make[1]: Leaving directory 'C:/build_untitled_Qt_5_6_0_Built_by_mingwx64_481r0_sjlj_rev2_Debug'
Makefile:34: recipe for target 'debug' failed
mingw32-make: *** [debug] Error 2
09:06:33: The process "C:mingwmingwx64_481r0-sjlj-rev2binmingw32-make.exe" exited with code 2.
Error while building/deploying project untitled (kit: Qt 5.6.0 (Built by mingwx64_481r0-sjlj-rev2))
When executing step "Make"

谢谢

我终于找到解决办法了。如果发生在我身上,也可能发生在任何人身上。实际上,在我安装gitbash之前,一切都工作了。我将gitbash的bin设置为变量system到我的路径系统。但是gitbach包含sh.exe这个unix工具。所以每次我通过Qtcreator或console 2构建时,uic_wrapper都被创建了一个。sh一个。bat,我所有的makefile都像unix一样。简而言之,永远不要在你的WINDOWS系统上设置任何UNIX工具。Mingw可以遏制MSYS,保重!!至少大多数面向开发的工具都是类似UNIX的。

我怀疑你的桌面套件可能有问题。我试着创建一个新的默认mainwindow项目,就像你做的那样,我看到了下面的前几个步骤:

14:48:15: Running steps for project untitled...
14:48:15: Starting: "D:QtQt5.6.05.6mingw49_32binqmake.exe" C:untitleduntitled.pro -r -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"
14:48:16: The process "D:QtQt5.6.05.6mingw49_32binqmake.exe" exited normally.
14:48:16: Starting: "D:QtQt5.6.0Toolsmingw492_32binmingw32-make.exe" 
D:/Qt/Qt5.6.0/Tools/mingw492_32/bin/mingw32-make -f Makefile.Debug

您可以注意到我的应用程序与您的应用程序使用的qmake路径之间存在差异。

Mine looks like this: D:QtQt5.6.05.6mingw49_32binqmake.exe
Yours looks like this: D:QTqt-everywhere-opensource-src-5.6.0qtbasebinqmake.exe

我猜qt-everywhere-opensource-src-5.6.0看起来像Qt源代码,你可能已经从网络上拉。希望这些信息能给你一些提示,帮助你找出问题所在。