简体   繁体   English

如何为 Windows 构建 Qt?

[英]How to build Qt for Windows?

I am trying to get Qt working for Windows.我试图让 Qt 为 Windows 工作。 I am starting at: https://wiki.qt.io/Building_Qt_5_from_Git#Getting_the_source_code .我从: https://wiki.qt.io/Building_Qt_5_from_Git#Getting_the_source_code开始。

I could clone the Git repository, but nothing works then:我可以克隆 Git 存储库,但没有任何效果:

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

It brings me error on command not found:它给我带来了找不到命令的错误:

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

The files configure and configure.bat exist in the right place... Running nmake brings an error on a missing makefile...文件 configure 和 configure.bat 存在于正确的位置...运行 nmake 会导致缺少 makefile 的错误...

I didn't see there was a binary and I installed it.我没有看到有二进制文件,我安装了它。 Now, in QtCreator, I have another problem.现在,在 QtCreator 中,我遇到了另一个问题。 I try to add a new empty project, and when I must enter a kit I got this: capture:我尝试添加一个新的空项目,当我必须输入一个工具包时,我得到了这个:捕获:
捕获

What must I do?我必须做什么? I can't select anyone.我不能 select 任何人。

After reinstalling Qt, I could find the kits, but when I compile a simple program:重新安装 Qt 后,我可以找到套件,但是当我编译一个简单的程序时:

#include <QApplication>

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

    return app.exec();
}

I got this error:我收到了这个错误:

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)

Finally adding CONFIG += console to the.pro file fixed the issue.最后将 CONFIG += console 添加到 .pro 文件解决了这个问题。

Here are the commands I use to compile Qt5 under Windows (you'll need to update the paths and options to suit your situation of course):以下是我用来在 Windows 下编译 Qt5 的命令(当然,您需要更新路径和选项以适应您的情况):

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

(On the very latest versions of Qt, eg 5.15.4, you can call jom instead of nmake in order to get a faster compile) (在 Qt 的最新版本上,例如 5.15.4,您可以调用 jom 而不是 nmake 以获得更快的编译)

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

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