繁体   English   中英

如何为 Windows 构建 Qt?

[英]How to build Qt for Windows?

我试图让 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 中,我遇到了另一个问题。 我尝试添加一个新的空项目,当我必须输入一个工具包时,我得到了这个:捕获:
捕获

我必须做什么? 我不能 select 任何人。

重新安装 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 += console 添加到 .pro 文件解决了这个问题。

以下是我用来在 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 以获得更快的编译)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM