Qt 打包建议

发行版可能需要打包多个不同的 Qt 版本。以 Linux 发行版为例,我们建议采用以下方法:

  • 将 Qt 配置为将可执行文件安装到/usr/qt6/bin 。
  • 在/usr/bin 目录下,为位于/usr/qt6/bin 目录中的面向用户的应用程序创建带有版本后缀的符号链接。例如,创建符号链接/usr/bin/designer6 ,使其指向/usr/qt6/bin/designer 。

面向用户的应用程序是指应由用户启动的 Qt 工具。这包括 qmake、Qt Widgets Designer 、Qt Linguist 等。其他工具,如 moc、rcc 和 uic,通常不会由用户手动调用,而是由用户项目的构建系统调用。

在 Qt 的构建系统中,我们视为面向用户的工具会被相应标记,该信息可通过以下方式提取并使用。

使用以下 CMake 参数配置 Qt:

-DCMAKE_INSTALL_PREFIX=/usr
-DINSTALL_BINDIR=/usr/qt6/bin
-DINSTALL_PUBLICBINDIR=/usr/bin

这将在 Qt 的构建目录中生成一个名为user_facing_tool_links.txt 的文件。该文件的每一行包含INSTALL_BINDIR 中面向用户的工具路径,以及以一个空格分隔的INSTALL_PUBLICDIR 中带版本号的符号链接路径。

该文件可用于创建所有带版本号的符号链接:

xargs ln -s < user_facing_tool_links.txt

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.