linux Qt程序打包(linuxdeployqt工具的使用)
官方提供的最新版本基于Qt5.8的,用户可根据须要从源码编译成本机版原本使用,具体操做过程以下:linux
工具
1.linuxdeployqt
依赖工具:
patchelf(必须)
appimagetool(可选)
2.Qt
确保机器已经安装Qtapp
若是须要制做成单文件程序,须要用到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.net
执行qmake以前先设置环境变量PATH命令行
export PATH=~/Qt5.xx.x/5.x/gcc_xx/bin:$PATH
1
而后执行下debug
qmake -v
1
查看下当前使用的qmake是否为你须要的版本
设置完成后在linuxdeployqt项目目录下直接执行qmake,而后再执行make便可,不须要make installorm
1.3 这样编译好后的可执行文件位于linuxdeployqt/linuxdeployqt下,将其复制至系统程序可执行目录下便可blog
sudo mv linuxdeployqt/linuxdeployqt /usr/local/bin
1
2.patchelf的编译与安装
操做步骤:ip
./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=<path> : Let the given executable use the deployed libraries too
-qmldir=<path> : 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