【问题标题】:How to build Qt for Windows?如何为 Windows 构建 Qt?
【发布时间】:2021-06-08 13:31:54
【问题描述】:

我正在尝试让 Qt 为 Windows 工作。我开始于:https://wiki.qt.io/Building_Qt_5_from_Git#Getting_the_source_code

我可以克隆 Git 存储库,但没有任何效果:

..\\qt5\configure -developer-build -opensource -nomake examples -nomake tests

它给我带来了找不到命令的错误:

   + CategoryInfo          : ObjectNotFound: (../qt5/configure:String) [], CommandNotFoundException
   + FullyQualifiedErrorId : CommandNotFoundException

文件 configure 和 configure.bat 存在于正确的位置... 运行 nmake 会导致缺少 makefile 的错误...

我没有看到有二进制文件,我安装了它。 现在,在 QtCreator 中,我遇到了另一个问题。我尝试添加一个新的空项目,当我必须输入一个工具包时,我得到了这个: 捕获:

我必须做什么?我无法选择任何人。

重新安装Qt后,我可以找到工具包,但是当我编译一个简单的程序时:

#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    return app.exec();
}

我收到了这个错误:

MSVCRTD.lib(exe_winmain.obj):-1: error: LNK2019: unresolved external symbol  WinMain r‚f‚renc‚ in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)

最后将 CONFIG += 控制台添加到 .pro 文件解决了这个问题。

【问题讨论】:

  • 你用的是什么编译器,你也在用cmake吗?请更准确。
  • 看起来您没有按照 Windows 说明操作,请使用反斜杠而不是正斜杠
  • 不,我使用了正确的语法,这是我复制/粘贴代码的错误,对不起。
  • 我使用:..\\qt5\configure -developer-build -opensource -nomake examples -nomake 测试。我不知道如何更精确,我不使用 cmake,我只是按照 qt 链接上的说明进行操作。没有任何工作。
  • 您的子系统是什么,是 Subsytem:Windows 还是 Subsystem:Console?使用 main() 意味着使用 Subsystem:Console 或 mainCRTStartup

标签: c++ qt


【解决方案1】:

以下是我在 Windows 下编译 Qt5 时使用的命令(当然,您需要更新路径和选项以适应您的情况):

cd C:\Qt\qt-everywhere-opensource-src-5.xx.y
configure -prefix %CD%\qtbase -opensource -nomake tests -nomake examples
nmake

(在 Qt 的最新版本中,例如 5.15.4,您可以调用 jom 而不是 nmake 以获得更快的编译)

【讨论】:

  • 谢谢,我找到了要安装的二进制文件,但是我上面提到了一个小问题
猜你喜欢
  • 1970-01-01
  • 2017-08-13
  • 2012-12-19
  • 1970-01-01
  • 2016-01-11
  • 2012-01-08
  • 2015-05-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多