如何在Windows下使用qmake链接一个针对xmlpatterns的Qt应用程序

How to link a Qt application against xmlpatterns with qmake under Windows

本文关键字:一个 xmlpatterns 应用程序 Qt Windows 链接 qmake      更新时间:2023-10-16

我有以下.pro文件:

TEMPLATE = app
QT += qml quick xmlpatterns
CONFIG += c++11
SOURCES += main.cpp
RESOURCES += qml.qrc

此外,我在我的Qt项目中有以下main.cpp(在Qt Creator中,使用Qt 5.5):

#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QtXmlPatterns>
int main(int argc, char *argv[])
{
  QXmlSchema schema;
  QGuiApplication app(argc, argv);
  QQmlApplicationEngine engine;
  engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
  return app.exec();
}

尽管我的Qt安装中的xmlpatterns示例进行了编译,但这段代码并不编译。我在这里错过了什么???

Qt Creator找不到标题QtXmlPatterns(它存在,我检查过了),如果我替换

#include <QtXmlPatterns>

带有

#include <QtXmlPatterns/QtXmlPatterns>

Qt创建者找到了标头,但无法链接到QtXmlPatterns lib:

main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QXmlSchema::QXmlSchema(void)" (__imp_??0QXmlSchema@@QAE@XZ) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QXmlSchema::~QXmlSchema(void)" (__imp_??1QXmlSchema@@QAE@XZ) referenced in function _main
debugBrainReliefer.exe : fatal error LNK1120: 2 unresolved externals

如何编译此应用程序?

我终于升级到了Qt 5.6,它开始工作了。