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

查看:117
本文介绍了如何使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天全站免登陆