在 Linux 上构建 Qt 5,适用于 Windows [英] Building Qt 5 on Linux, for Windows

查看:58
本文介绍了在 Linux 上构建 Qt 5,适用于 Windows的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想迁移我的 Qt 4 应用程序以改用 Qt 5.这些说明失败,原因是与MXE 构建 Qt 5,包括它使用模块化 Qt tarball 而不是一个大型 tarball 这一事实.

I wanted to migrate my Qt 4 app to use Qt 5 instead. These instructions failed, due to some differences with how MXE builds Qt 5, including the fact that it uses modularised Qt tarballs, instead of one large tarball.

推荐答案

以下是完整说明:

  • 获取:

git clone https://github.com/mxe/mxe.git

  • 安装构建依赖项

    为 Windows 构建 Qt 5:

    Build Qt 5 for Windows:

    cd mxe && make qtbase
    

    这将首先构建其依赖项和交叉构建工具;在具有良好互联网访问权限的快速机器上应该需要不到一个小时的时间.

    This will first build its dependencies and the cross-build tools; It should take less than an hour on a fast machine with decent internet access.

    由于 Qt 5 的新模块化特性,各种主要的 Qt 组件现在位于不同的 tarball 中.上面选择的那个 qtbase 应该给你足够的功能来运行普通的 GUI 应用程序,这是我自己的(小)应用程序所需要的.

    Due to the new modular nature of Qt 5, various major Qt components are now in different tarballs. The one selected above, qtbase, should give you enough functionality to run ordinary GUI apps, which is all I needed for my own (smallish) app.

    如果您想构建所有 Qt 5,则需要运行 make qt5(而不是 make qtbase).请注意,完成此操作需要更长的时间,因此请确保您需要额外的功能.

    If you want to build all of Qt 5 instead, you'll need to run make qt5 (instead of make qtbase). Note that it will take a lot longer to complete, so be sure that you need the extra functionality.

    进入您的应用程序目录,并运行 Qt Makefile 生成器工具:

    Get to the directory of your app, and run the Qt Makefile generator tool:

    <mxe root>/usr/bin/i686-w64-mingw32.static-qmake-qt5
    

  • 构建您的项目:

  • Build your project:

    make
    

  • 您应该在 ./release 目录中找到二进制文件:

  • You should find the binary in the ./release directory:

    wine release/foo.exe
    

  • 一些注意事项:

    • 这已经在我的 64 位 Debian 8 和 Windows 上进行了测试.

    • This was tested on my 64-bit Debian 8, and on Windows of course.

    输出是一个 32 位静态可执行文件,可在 64 位 Windows 上正常运行.

    The output is a 32-bit static executable, which will work well on 64-bit Windows.

    如果您需要 64 位可执行文件,请使用以下命令构建 Qt:

    If you want a 64-bit executable, build Qt with:

    make MXE_TARGETS=x86_64-w64-mingw32.static qtbase
    

    默认的 MXE_TARGETS 值为 i686-w64-mingw32.static.

    这篇关于在 Linux 上构建 Qt 5,适用于 Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆