qt程序使用多行linux命令,linux Qt程序打包(linuxdeployqt工具的使用)

linux Qt程序打包(linuxdeployqt工具的使用)

官方提供的最新版本基于Qt5.8的,用户可根据需要从源码编译成本机版本来使用,具体操作过程如下:

工具

1.linuxdeployqt

依赖工具:

patchelf(必须)

appimagetool(可选)

2.Qt

确保机器已经安装Qt

如果需要制作成单文件程序,需要用到appimagetool,若不需要可不必下载

步骤

官网提供详细步骤,这里说下注意事项

下载下来的linuxdeployqt

1.1 (界面编译)打开QtCreator,打开linuxdeployqt项目,直接构建即可,构建完成后在linuxdeployqt目录下可找到编译好的可执行文件(linuxdeployqt)

1.2 (命令行)打开终端,进入linuxdeployqt项目目录,目录结构如下:

ls

BUILDING.md LICENSE.LGPLv3 linuxdeployqt.pro shared

Dockerfile linuxdeployqt Makefile tests

LICENSE.GPLv3 linuxdeployqt.AppDir README.md

执行qmake之前先设置环境变量PATH

export PATH=~/Qt5.xx.x/5.x/gcc_xx/bin:$PATH

1

然后执行下

qmake -v

1

查看下当前使用的qmake是否为你需要的版本

设置完成后在linuxdeployqt项目目录下直接执行qmake,然后再执行make即可,不需要make install

1.3 这样编译好后的可执行文件位于linuxdeployqt/linuxdeployqt下,将其复制至系统程序可执行目录下即可

sudo mv linuxdeployqt/linuxdeployqt /usr/local/bin

1

2.patchelf的编译与安装

操作步骤:

./configure

make

sudo make install (直接安装至系统目录即可)

关于 appimagetool 的安装参照官网即可,直接用wget下载可能比较慢,可用迅雷或其他下载工具下载下来,然后拷贝至linux系统,具体操作步骤:

suco cp ppimagetool-x86_64.AppImage /usr/local/bin/appimagetool

sudo chmod a+x /usr/local/bin/appimagetool

1

2

使用方法

命令:

linuxdeployqt ~/path/to/project/application -appimage

appimage:若根据操作安装了 appimagetool 时该参数有效,使用该参数可将你需要打包的程序打包成单个文件;

其他相关参数

Options:

-verbose=<0-3>      : 0 = no output, 1 = error/warning (default), 2 = normal, 3 = debug

-no-plugins         : Skip plugin deployment

-appimage           : Create an AppImage

-no-strip           : Don't run 'strip' on the binaries

-bundle-non-qt-libs : Also bundle non-core, non-Qt libraries

-executable=  : Let the given executable use the deployed libraries too

-qmldir=      : Scan for QML imports in the given path

-always-overwrite   : Copy files even if the target file exists

linuxdeployqt takes an application as input and makes it

self-contained by copying in the Qt libraries and plugins that

the application uses.

1

2

3

4

5

6

7

8

9

10

11

12

官方文档

create by vacant. 转载请注明

————————————————

版权声明:本文为CSDN博主「vacantChan」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/enaldick12/article/details/63255934

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值