【问题标题】:Unable to Compile a Qt project in qtcreator无法在 qtcreator 中编译 Qt 项目
【发布时间】:2016-06-30 07:10:02
【问题描述】:

我无法编译一个简单的 Qt 项目(带有主窗口的示例)。我通过命令外壳和 QtCreator 进行了尝试。首先 qmake 应该使用命令规则 uic 创建 makefile 以将我的 ui 转换为 .h 一样简单。

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

09:06:30: Running steps for project untitled...
09:06:30: Starting: "D:\QT\qt-everywhere-opensource-src-5.6.0\qtbase\bin\qmake.exe" C:\workspace_llb_27-05-2016\untitled\untitled.pro -r -spec win32-g++
09:06:32: The process "D:\QT\qt-everywhere-opensource-src-5.6.0\qtbase\bin\qmake.exe" exited normally.
09:06:32: Starting: "C:\mingw\mingwx64_481r0-sjlj-rev2\bin\mingw32-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:\mingw\mingwx64_481r0-sjlj-rev2\bin\mingw32-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"

谢谢

【问题讨论】:

  • 由于某种原因,它看起来像 ui_mainwindow.h 不存在,可能 uic_wrapper 无法生成它。我建议尝试仅单独编译 mainwindow.ui,看看是否可行。
  • 感谢您的回复马可。它似乎不起作用。我打开命令提示符,在那里我得到了 ui_wrapper.bat 和我的 mainwindow.ui 然后我运行命令行 uic_wrapper.bat -o mainwindow.ui ui_mainwindow.h 但它不起作用,它应该是调用 uic.exe 的生成文件

标签: c++ qt build qmake


【解决方案1】:

我最终找到了解决方案。如果它发生在我身上,它可能发生在任何人身上。实际上在我安装 gitbash 之前一切正常。我将 gitbash 的 bin 设置为变量系统到我的路径系统。但是 gitbach 包含 sh.exe 哪个 unix 工具。因此,每次我通过 Qtcreator 或控制台 2 构建 uic_wrapper 时,都会创建一个 .sh 和一个 .bat,并且我所有的 makefile 都类似于 unix。简而言之,永远不要为您的 WINDOWS 系统设置任何 UNIX 工具。 Mingw 可以包含 MSYS 小心!至少大多数面向工具的开发都类似于 UNIX。

【讨论】:

  • 哇,谢谢,它解决了我的问题。我已经从路径中删除了 sh.exe,然后再次运行 Qmake,现在 Makefile 使用 Windows 命令而不是 Unix(例如 cp => copy、rm => remove 等)。
【解决方案2】:

我怀疑您的 Desktop Kit 可能有问题。我尝试像您一样创建一个新的默认 mainwindow 项目,我看到的前几个步骤如下所示:

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

您会注意到我的应用程序使用的qmake 路径与您的不同。

Mine looks like this: D:\Qt\Qt5.6.0\5.6\mingw49_32\bin\qmake.exe
Yours looks like this: D:\QT\qt-everywhere-opensource-src-5.6.0\qtbase\bin\qmake.exe

我猜qt-everywhere-opensource-src-5.6.0 看起来像是您可能从网络上提取的 Qt 源代码。希望这些信息可以为您提供一些指示,以找出问题所在。

【讨论】:

  • 非常感谢您的帮助。我从来没有注意到这一点。我真正的 Qt 工具路径是 D:\QT\qt-everywhere-opensource-src-5.6.0\qtbase\bin\qmake.exe。它在我的构建目录中正确生成 uic_wrapper.bat,但在 makefile.Debug 中失败。但是当我像这样运行 uic_wrapper.bat 时:uic_wrapper.bat -o ui_mainwindow.h mainwindow.ui。我可以进入我的 ui_mainwindow.h 文件,然后运行我的项目。我不知道杂物在哪里
  • 我注意到 makefile 中有一些东西。即使我像这样启动qmake:qmake.exe untitled.pro -r -spec win32-g++ 我也可以在makefile中找到像rm -f或\而不是/这样的linux命令。 qmake 在创建 makefile 时使用 linux 命令到底是什么。
  • 我仍在努力解决这个问题。我很确定它来自错误的环境。我将 makefile.debug uic_wrapper.sh 更改为 .bat 但没有任何改变。这是我在 qtcreator 中的输出控制台。
  • /build_untitled_Qt_5_6_0_Built_by_mingwx64_481r0_sjlj_rev2_Debug/uic_wrapper.bat ../untitled/mainwindow.ui -o ui_mainwindow.h Makefile.Debug:318: 目标“ui_mainwindow.h”的配方失败 process_begin: CreateProcess(NULL, /C /workspace_llb_27-05-2016/build_untitled_Qt_5_6_0_Built_by_mingwx64_481r0_sjlj_rev2_Debug/uic_wrapper.bat ../untitled/mainwindow.ui -o ui_mainwindow.h, ...) 失败。 make (e=2): Le fichier spécifié est introuvable。
  • 如果可以提供一些线索,请尝试检查此POST。如果没有帮助,您能否给我您正在使用的桌面套件的屏幕截图。您可以在tools->options->build & run->kits->(desktop kit or similar) 下找到
猜你喜欢
  • 1970-01-01
  • 2023-02-02
  • 1970-01-01
  • 2023-03-11
  • 2018-04-19
  • 2011-05-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多