win10
QT5.7
我尝试通过cmd编译QT项目
C:\Qt\Qt5.7.1\Examples\Qt-5.7\quick\demos\clocks>qmake -project
C:\Qt\Qt5.7.1\Examples\Qt-5.7\quick\demos\clocks>qmake
C:\Qt\Qt5.7.1\Examples\Qt-5.7\quick\demos\clocks>mingw32-make
输出:
mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory 'C:/Qt/Qt5.7.1/Examples/Qt-5.7/quick/demos/clocks'
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=gnu++11 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I. -I. -IC:\Qt\Qt5.7.1\5.7\mingw53_32\include -IC:\Qt\Qt5.7.1\5.7\mingw53_32\include\QtGui -IC:\Qt\Qt5.7.1\5.7\mingw53_32\include\QtANGLE -IC:\Qt\Qt5.7.1\5.7\mingw53_32\include\QtCore -Irelease -IC:\Qt\Qt5.7.1\5.7\mingw53_32\mkspecs\win32-g++ -o release\main.o main.cpp
In file included from main.cpp:40:0:
../../shared/shared.h:42:22: fatal error: QQmlEngine: No such file or directory
compilation terminated.
Makefile.Release:198: recipe for target 'release/main.o' failed
mingw32-make[1]: *** [release/main.o] Error 1
mingw32-make[1]: Leaving directory 'C:/Qt/Qt5.7.1/Examples/Qt-5.7/quick/demos/clocks'
Makefile:34: recipe for target 'release' failed
mingw32-make: *** [release] Error 2
这是QT的演示示例,它在Qt创建者中运行良好。但在cmd报告错误。无论我编译哪个演示,它们都会报告从../../shared/shared.h:42:22: fatal error: QQmlEngine: No such file or directory
P.S。:
实际上,我真正想做的是在sublime3中编译Qt项目,该项目失败并且没有输出。我开始使用cmd来查找错误,并发现了这个错误
我的sublime3构建系统遵循这篇文章Build system for Qt in Sublime Text 3 not working
添加.pro文件
######################################################################
# Automatically generated by qmake (3.0) ?? 5? 29 09:05:15 2018
######################################################################
TEMPLATE = app
TARGET = clocks
INCLUDEPATH += .
# Input
HEADERS += ../../shared/shared.h
SOURCES += main.cpp
RESOURCES += clocks.qrc
这是qt演示所写的内容
更新
感谢评论,我在.pro文件中添加了QT += qml quick
并解决了问题。虽然我不知道为什么qmake -project commmand生成的pro文件缺少该语句
答案 0 :(得分:1)
感谢评论,我在.pro文件中快速添加QT + = qml并解决问题。