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

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

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


工具


1.linuxdeployqt

2.Qt

确保机器已经安装Qt

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

步骤


  1. 官网提供详细步骤,这里说下注意事项
    下载下来的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

然后执行下

qmake -v 

查看下当前使用的qmake是否为你需要的版本
设置完成后在linuxdeployqt项目目录下直接执行qmake,然后再执行make即可,不需要make install

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

sudo mv linuxdeployqt/linuxdeployqt /usr/local/bin

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

使用方法


  • 命令:
    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.

官方文档

create by vacant. 转载请注明

猜你喜欢

转载自blog.csdn.net/enaldick12/article/details/63255934
今日推荐