如何为 Linux 制作 Qt 应用程序的二进制分发版 [英] How to make binary distribution of Qt application for Linux

查看:31
本文介绍了如何为 Linux 制作 Qt 应用程序的二进制分发版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发跨平台 Qt 应用程序.它是免费软件,虽然不是开源的.因此,我想将其作为编译后的二进制文件分发.

I am developing cross-platform Qt application. It is freeware though not open-source. Therefore I want to distribute it as a compiled binary.

在 Windows 上没有问题,我将编译后的 exe 与 MinGW 和 Qt 的 DLL 打包在一起,一切都很好.

On windows there is no problem, I pack my compiled exe along with MinGW's and Qt's DLLs and everything goes great.

但在 Linux 上存在一个问题,因为用户可能在他/她的系统中拥有与我的系统非常不同的共享库.

But on Linux there is a problem because the user may have shared libraries in his/her system very different from mine.

Qt 部署指南推荐了两种方法:静态链接和使用共享库.第一个产生巨大的可执行文件,并且还需要 Qt 所依赖的许多库的静态版本,即我必须从头开始重建所有这些库.第二种方法是在应用程序启动之前重新配置动态链接器,对我来说似乎有点棘手.

Qt deployment guide suggests two methods: static linking and using shared libraries. The first produces huge executable and also require static versions of many libraries which Qt depends on, i.e. I'll have to rebuild all of them from scratches. The second method is based on reconfiguring dynamic linker right before the application startup and seems a bit tricky to me.

谁能分享他/她在 Linux 下分发 Qt 应用程序的经验?我应该使用什么方法?我可能会遇到哪些问题?有没有其他方法可以完成这项工作?

Can anyone share his/her experience in distributing Qt applications under Linux? What method should I use? What problems may I confront with? Are there any other methods to get this job done?

推荐答案

您还可以在 Linux 上分发 Qt 共享库.然后,让您的软件加载这些而不是系统默认的.可以使用 LD_LIBRARY_PATH 环境变量覆盖共享库.这对您来说可能是最简单的解决方案.您始终可以在可执行文件的包装脚本中更改此设置.

You can also distribute Qt shared libraries on Linux. Then, get your software to load those instead of the system default ones. Shared libraries can be over-ridden using the LD_LIBRARY_PATH environment variable. This is probably the simplest solution for you. You can always change this in a wrapper script for your executable.

或者,只需指定您的用户需要在系统上安装的最低库版本.

Alternatively, just specify the minimum library version that your users need to have installed on the system.

这篇关于如何为 Linux 制作 Qt 应用程序的二进制分发版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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