linuxdeployqt-linux下Qt打包工具

linuxdeployqt

简介

基于Windows-Qt 发布的打包工具windeployqt,主要打包Qt相关依赖库,但是在linux,qt官方并未发布对应的打包版本。在github中,有人开源了这个版本linuxdeployqt,之前一直知道但是没怎么用,最近因为要打包对应工程,又拿出研究了一下。

  • Windows介绍
The Windows deployment tool windeployqt is designed to automate the process of creating a deployable folder containing the Qt-related dependencies (libraries, QML imports, plugins, and translations) required to run the application from that folder. It creates a sandbox for Universal Windows Platform (UWP) or an installation tree for Windows desktop applications, which can be easily bundled into an installation package.

看一下Windows命令。

Qt Deploy Tool 6.0.3

The simplest way to use windeployqt is to add the bin directory of your Qt
installation (e.g. <QT_DIR\bin>) to the PATH variable and then run:
  windeployqt <path-to-app-binary>
If ICU, etc. are not in the bin directory, they need to be in the PATH
variable. If your application uses Qt Quick, run:
  windeployqt --qmldir <path-to-app-qml-files> <path-to-app-binary>

Options:
  -?, -h, --help              Displays help on commandline options.
  --help-all                  Displays help including Qt specific options.
  -v, --version               Displays version information.
  --dir <directory>           Use directory instead of binary directory.
  --qmake <path>              Use specified qmake instead of qmake from PATH.
  --libdir <path>             Copy libraries to path.
  --plugindir <path>          Copy plugins to path.
  --debug                     Assume debug binaries.
  --release                   Assume release binaries.
  --pdb                       Deploy .pdb files (MSVC).
  --force                     Force updating files.
  --dry-run                   Simulation mode. Behave normally, but do not
                              copy/update any files.
  --no-patchqt                Do not patch the Qt6Core library.
  --ignore-library-errors     Ignore errors when libraries cannot be found.
  --no-plugins                Skip plugin deployment.
  --no-libraries              Skip library deployment.
  --qmldir <directory>        Scan for QML-imports starting from directory.
  --qmlimport <directory>     Add the given path to the QML module search
                              locations.
  --no-quick-import           Skip deployment of Qt Quick imports.
  --translations <languages>  A comma-separated list of languages to deploy
                              (de,fi).
  --no-translations           Skip deployment of translations.
  --no-system-d3d-compiler    Skip deployment of the system D3D compiler.
  --compiler-runtime          Deploy compiler runtime (Desktop only).
  --no-virtualkeyboard        Disable deployment of the Virtual Keyboard.
  --no-compiler-runtime       Do not deploy compiler runtime (Desktop only).
  --json                      Print to stdout in JSON format.
  --no-opengl-sw              Do not deploy the software rasterizer library.
  --list <option>             Print only the names of the files copied.
                              Available options:
                               source:   absolute path of the source files
                               target:   absolute path of the target files
                               relative: paths of the target files, relative
                                         to the target directory
                               mapping:  outputs the source and the relative
                                         target, suitable for use within an
                                         Appx mapping file
  --verbose <level>           Verbose level (0-2).

Qt libraries can be added by passing their name (-xml) or removed by passing
the name prepended by --no- (--no-xml). Available libraries:
bluetooth concurrent core declarative designer designercomponents gamepad gui
qthelp multimedia multimediawidgets multimediaquick network nfc opengl
openglwidgets positioning printsupport qml qmltooling quick quickparticles
quickwidgets script scripttools sensors serialport sql svg svgwidgets test
websockets widgets winextras xml webenginecore webengine webenginewidgets 3dcore
3drenderer 3dquick 3dquickrenderer 3dinput 3danimation 3dextras geoservices
webchannel texttospeech serialbus webview

Arguments:
  [files]                     Binaries or directory containing the binary.
  • linux介绍
This Linux Deployment Tool, linuxdeployqt, takes an application as input and makes it self-contained by copying in the resources that the application uses (like libraries, graphics, and plugins) into a bundle. The resulting bundle can be distributed as an AppDir or as an AppImage to users, or can be put into cross-distribution packages. It can be used as part of the build process to deploy applications written in C, C++, and other compiled languages with systems like CMake, qmake, and make. When used on Qt-based applications, it can bundle a specific minimal subset of Qt required to run the application.

帮助文档:

linuxdeployqt 7 (commit d41e234), build <local dev build> built on 2021-05-31 09:46:09 UTC

Usage: linuxdeployqt <app-binary|desktop file> [options]

Options:
   -always-overwrite        : Copy files even if the target file exists.
   -appimage                : Create an AppImage (implies -bundle-non-qt-libs).
   -bundle-non-qt-libs      : Also bundle non-core, non-Qt libraries.
   -exclude-libs=<list>     : List of libraries which should be excluded,
                              separated by comma.
   -ignore-glob=<glob>      : Glob pattern relative to appdir to ignore when
                              searching for libraries.
   -executable=<path>       : Let the given executable use the deployed libraries
                              too
   -extra-plugins=<list>    : List of extra plugins which should be deployed,
                              separated by comma.
   -no-copy-copyright-files : Skip deployment of copyright files.
   -no-plugins              : Skip plugin deployment.
   -no-strip                : Don't run 'strip' on the binaries.
   -no-translations         : Skip deployment of translations.
   -qmake=<path>            : The qmake executable to use.
   -qmldir=<path>           : Scan for QML imports in the given path.
   -qmlimport=<path>        : Add the given path to QML module search locations.
   -show-exclude-libs       : Print exclude libraries list.
   -verbose=<0-3>           : 0 = no output, 1 = error/warning (default),
                              2 = normal, 3 = debug.
   -updateinformation=<update string>        : Embed update information STRING; if zsyncmake is installed, generate zsync file
   -version                 : Print version statement and exit.

linuxdeployqt takes an application as input and makes it
self-contained by copying in the Qt libraries and plugins that
the application uses.

By default it deploys the Qt instance that qmake on the $PATH points to.
The '-qmake' option can be used to point to the qmake executable
to be used instead.

Plugins related to a Qt library are copied in with the library.

See the "Deploying Applications on Linux" topic in the
documentation for more information about deployment on Linux.

编译

下载

git clone https://github.com/probonopd/linuxdeployqt.git -b 7 --depth 1

博主下载了 tag 7

编译-安装

cd linuxdeployqt
mkdir build
cd build
qmake ../linuxdeployqt.pro
make -j
sudo make install
#安装路径:/opt/Qt/Qt5.9.5/5.9.5/gcc_64/bin/linuxdeployqt 。Qt默认安装路径。
#ln -s /opt/Qt/Qt5.9.5/5.9.5/gcc_64/bin/linuxdeployqt /usr/bin/linuxdeployqt 配置为全局可执行程序

其他相关库下载:

#动态链接库工具(链接、重定向)
wget https://nixos.org/releases/patchelf/patchelf-0.9/patchelf-0.9.tar.bz2
tar xf patchelf-0.9.tar.bz2
( cd patchelf-0.9/ && ./configure  && make && sudo make install )
#注意:根据对应平台下载(桌面-app生成工具)
sudo wget -c "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage" -O /usr/local/bin/appimagetool
sudo chmod a+x /usr/local/bin/appimagetool

测试

linuxdeployqt配置为全局可执行程序后。开始测试:

linuxdeployqt ./xxxx -verbose=2 -appimage
#-verbose=<0-3> : 0 = no output, 1 = error/warning (default),2 = normal, 3 = debug.
#-appimage      : Create an AppImage (implies -bundle-non-qt-libs).

输出:

Log: Creating  "xxxxxxxxxx/translations/qt_tterns_uk.qm" ...
Log: "appimagetool -v 'xxxxxxxxxx' -n -g"
appimagetool, continuous build (commit 8bbf694), build <local dev build> built on 2020-12-31 11:48:33 UTC
NOTE: Using the output of 'git rev-parse --short HEAD' as the version:
      2eb7984
      Please set the $VERSION environment variable if this is not intended
Desktop file: xxxxxxxxxxx/default.desktop
Categories entry not found in desktop file
.desktop file is missing a Categories= key
Log: ret 256
Log: WEXITSTATUS(ret) 1
  • 错误
linuxdeployqt ./RdpClient
linuxdeployqt 7 (commit d41e234), build <local dev build> built on 2021-05-31 09:46:09 UTC
FHS-like mode with PREFIX, fhsPrefix: "/../.."
QDir::exists: Empty or null file name
ERROR: Error: Could not find app-binary ""

安装包

安装包路径

下载完之后,给与可执行权限chmod a+x linuxdeployqt-continuous-x86_64.AppImage,全局环境变量配置mv linuxdeployqt-continuous-x86_64.AppImage /usr/bin ,或者按照上述安装路径,mv linuxdeployqt-continuous-x86_64.AppImagelinuxdeployqt /opt/Qt/Qt5.9.5/gcc/bin/linuxdeployqt

注意事项

生成文件:

AppRun  default.desktop  default.png  description-pak  doc  doc-pak  lib  Makefile    plugins  qt.conf  RdpClient  translations

实际使用过程中:

platformsplugins 应该位于同级目录。如下述。

AppRun  default.desktop  default.png  description-pak  doc  doc-pak  lib  Makefile  platforms  plugins  qt.conf  RdpClient  translations

而生成的目录路径如下:

├── plugins
│   ├── iconengines
│   ├── imageformats
│   ├── platforminputcontexts
│   ├── platforms
│   └── xcbglintegrations

需要做一个拷贝动作;mv lugins\platforms ./

然后在执行相关打包工作。

  • 2
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
### 回答1: linuxdeployqt-aarch64是一个用于在Aarch64架构上部署Qt应用程序的工具。 Aarch64是一种基于ARM的64位处理器架构。它在嵌入式系统和移动设备中广泛使用。Qt是一种跨平台的应用程序框架,可以用于开发图形用户界面(GUI)程序,它提供了一套丰富的库和工具linuxdeployqt-aarch64工具的作用是将使用Qt开发的应用程序打包为可在Aarch64架构上运行的独立可执行文件。它可以自动处理应用程序依赖的库文件、资源文件和插件,并将它们一起打包到生成的可执行文件中。这样,用户可以很方便地将Qt应用程序部署到Aarch64架构的设备上,而无需手动解决依赖关系和复制文件。 使用linuxdeployqt-aarch64工具,开发者只需要将其作为一个命令行工具运行,并指定应用程序的入口可执行文件以及其他必要的参数。工具将自动分析应用程序的依赖关系,将所需的库文件和资源文件复制到指定目录,并生成一个包含所有依赖项的独立可执行文件。这个可执行文件可以被直接在Aarch64架构的设备上运行,而无需手动安装任何额外的库文件。 总之,linuxdeployqt-aarch64工具是一个在Aarch64架构上部署Qt应用程序的便捷工具,可以帮助开发者将应用程序打包并快速部署到Aarch64设备上。它简化了应用程序的依赖管理和部署过程,为开发者提供了更好的开发体验。 ### 回答2: linuxdeployqt-aarch64是一个用于在ARM64架构上部署Qt应用程序的工具Qt是一种跨平台的应用程序开发框架,允许开发者在不同的操作系统上编写一次代码,然后部署到不同的平台上运行。 linuxdeployqt-aarch64为ARM64架构提供了一个简便的方式来打包和部署Qt应用程序。在使用linuxdeployqt-aarch64之前,开发者需要先在ARM64架构上安装Qt开发工具和依赖库。然后,通过linuxdeployqt-aarch64工具,开发者可以将编译好的Qt应用程序和相关的依赖库打包成一个独立的AppImage文件。AppImage是一种跨平台的应用程序打包格式,它包含了应用程序及其所有的依赖库和资源。 使用linuxdeployqt-aarch64打包的AppImage文件可以在支持ARM64架构的Linux系统上直接运行,无需进行额外的安装和配置。这个工具会自动解析和打包应用程序所依赖的Qt库、系统库以及其他的资源文件,确保应用程序能够在目标系统上正确运行。 总的来说,linuxdeployqt-aarch64是一个方便的工具,可用于在ARM64架构上部署Qt应用程序。它提供了一个简单的方式来打包和分发应用程序,使开发者能够更轻松地将Qt应用程序部署到ARM64架构的Linux系统上。 ### 回答3: linuxdeployqt-aarch64是一个用于在ARM64架构上部署和打包Qt应用程序的工具。ARM64是一种基于ARM架构的64位处理器架构,常用于移动设备和嵌入式系统。 linuxdeployqt-aarch64工具的作用是将Qt应用程序及其依赖的库和资源打包到一个独立的文件夹中,以便在其他Linux系统上运行。这个工具会自动解析应用程序的依赖关系,并将所需的库文件复制到适当的位置。 使用linuxdeployqt-aarch64的过程通常包括以下几个步骤: 1. 构建Qt应用程序的release版本。 2. 运行linuxdeployqt-aarch64工具并指定应用程序的路径。 3. 工具将自动扫描应用程序的依赖关系,并将所需的库文件和资源复制到一个独立的文件夹中。 4. 对生成的文件夹进行必要的调整和配置,例如添加启动脚本或修改权限等。 5. 将生成的文件夹打包,并在目标系统上进行安装和运行。 通过使用linuxdeployqt-aarch64,开发者可以方便地将Qt应用程序移植到ARM64架构的设备上,而不必手动处理依赖关系和库文件的复制问题。这大大简化了应用程序的部署过程,提高了开发效率。 总而言之,linuxdeployqt-aarch64是一个用于在ARM64架构上部署和打包Qt应用程序的工具,通过自动处理依赖关系和库文件复制,简化了应用程序的部署过程,提高了开发效率。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值