# linuxdeployqt [](https://github.com/probonopd/linuxdeployqt/actions)  [](http://discourse.appimage.org/t/linuxdeployqt-new-linux-deployment-tool-for-qt/57) [](https://gitter.im/probonopd/AppImageKit?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [](https://webchat.freenode.net/?channels=AppImage)
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](https://appimage.org/) 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.

## Differences to macdeployqt
This tool is conceptually based on the [Mac Deployment Tool](https://doc.qt.io/qt-5/macos-deployment.html#macdeploy), `macdeployqt` in the tools applications of the Qt Toolkit, but has been changed to a slightly different logic and other tools needed for Linux.
* Instead of an `.app` bundle for macOS, this produces an [AppDir](http://rox.sourceforge.net/desktop/AppDirs.html) for Linux
* Instead of a `.dmg` disk image for macOS, this produces an [AppImage](http://appimage.org/) for Linux which is quite similar to a dmg but executes the contained application rather than just opening a window on the desktop from where the application can be launched
## A note on binary compatibility
__To produce binaries that are compatible with many target systems, build on the oldest still-supported build system.__ The oldest still-supported release of Ubuntu is currently targeted, tested and supported by the team.
We recommend to target the oldest still-supported Ubuntu LTS release and build your applications on that. If you do this, the resulting binaries should be able to run on newer (but not older) systems (Ubuntu and other distributions).
We do not support linuxdeployqt on systems newer than the oldest Ubuntu LTS release, because we want to encourage developers to build applications in a way that makes them possible to run on all still-supported distribution releases. For an overview about the support cycles of Ubuntu LTS releases, please see https://wiki.ubuntu.com/Releases.
## Installation
Please download __linuxdeployqt-x86_64.AppImage__ from the [Releases](https://github.com/probonopd/linuxdeployqt/releases) page and `chmod a+x` it. If you would like to build `linuxdeployqt` from source instead, see [BUILDING.md](https://github.com/probonopd/linuxdeployqt/blob/master/BUILDING.md).
## Usage
```
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.
```
#### Simplest example
You'll need to provide the basic structure of an `AppDir` which should look something like this:
```
└── usr
├── bin
│ └── your_app
├── lib
└── share
├── applications
│ └── your_app.desktop
└── icons
└── <theme>
└── <resolution>
└── apps
└── your_app.png
```
Replace `<theme>` and `<resolution>` with (for example) `hicolor` and `256x256` respectively; see [icon theme spec](https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html) for more details.
Using the desktop file `linuxdeployqt` can determine the parameters of the build.
Where your desktop file would look something like:
```
[Desktop Entry]
Type=Application
Name=Amazing Qt App
Comment=The best Qt Application Ever
Exec=your_app
Icon=your_app
Categories=Office;
```
* Notice that both `Exec` and `Icon` only have file names.
* Also Notice that the `Icon` entry does not include an extension.
Read more about desktop files in the [Desktop Entry Specification 1.0](https://standards.freedesktop.org/desktop-entry-spec/1.0/).
Now you can say: `linuxdeployqt-continuous-x86_64.AppImage path/to/AppDir/usr/share/applications/your_app.desktop`
For a more detailed example, see "Using linuxdeployqt with Travis CI" below.
#### Checking library inclusion
Open in Qt Creator and build your application. Run it from the command line and inspect it with `ldd` to make sure the correct libraries from the correct locations are getting loaded, as `linuxdeployqt` will use `ldd` internally to determine from where to copy libraries into the bundle.
#### QMake configuration
__Important:__ By default, `linuxdeployqt` deploys the Qt instance that qmake on the $PATH points to, so make sure that it is the correct one. Verify that qmake finds the correct Qt instance like this before running the `linuxdeployqt` tool:
```
qmake -v
QMake version 3.0
Using Qt version 5.7.0 in /tmp/.mount_QtCreator-5.7.0-x86_64/5.7/gcc_64/lib
```
If this does not show the correct path to your Qt instance that you want to be bundled, then adjust your `$PATH` to find the correct `qmake`.
Alternatively, use the `-qmake` command line option to point the tool directly to the qmake executable to be used.
#### Remove unnecessary files
Before running linuxdeployqt it may be wise to delete unneeded files that you do not wish to distribute from the build directory. These may be
linuxdeployqt github源码
需积分: 0 199 浏览量
更新于2023-08-11
收藏 86KB GZ 举报
Linuxdeployqt是Qt开发中的一个实用工具,主要在Linux环境下用于构建可移植的Qt应用程序。这个工具是由 KDE 社区开发并维护的,它能够帮助开发者将Qt库和其他依赖项打包到应用程序的可执行文件旁边,使得应用在没有安装Qt环境的系统上也能正常运行。在GitHub上,你可以找到它的源码,这对于理解其工作原理、定制功能或参与开源项目非常有帮助。
让我们深入了解Linuxdeployqt的工作机制。Linuxdeployqt通过扫描你的Qt应用程序的可执行文件,识别出它所依赖的所有Qt模块和其他动态链接库。然后,它会把这些库复制到你的应用程序目录下,确保目标系统即使没有安装Qt也能运行程序。这个过程通常称为“部署”或者“捆绑”。
在GitHub上获取并编译Linuxdeployqt源码,你需要遵循以下步骤:
1. **克隆仓库**:你需要使用Git克隆Linuxdeployqt的GitHub仓库。这可以通过命令行完成:
```
git clone https://github.com/qt-applications/linuxdeployqt.git
```
2. **构建环境**:确保你的系统安装了Qt开发环境,包括Qt Creator、qmake以及相关的C++编译器。此外,由于Linuxdeployqt是KDE项目的一部分,你可能还需要安装一些KDE开发依赖项。
3. **配置和编译**:进入克隆的源码目录,使用qmake和make进行配置和编译:
```
cd linuxdeployqt
qmake
make
```
4. **安装**:编译完成后,你可以选择将二进制文件安装到系统的可执行路径:
```
sudo make install
```
5. **使用**:现在,你可以用编译好的`linuxdeployqt`工具来部署你的Qt应用。例如:
```
./linuxdeployqt your_app_path -qmake /path/to/qmake
```
在了解Linuxdeployqt的工作原理后,我们可以深入探讨Qt开发的一些关键概念:
1. **Qt模块**:Qt库由多个模块组成,如Widgets、Core、Gui、Network等。每个模块都提供了特定的功能,开发者可以根据需求选择使用哪些模块。
2. **动态链接与静态链接**:Linuxdeployqt处理的是动态链接的问题。动态链接库在运行时被加载,允许程序占用更少的磁盘空间,但需要目标系统有相应的库。静态链接则将所有依赖项编译进可执行文件,确保在任何系统上都能运行,但文件体积较大。
3. **Qt Creator**:这是一个集成开发环境(IDE),为Qt开发提供了便捷的代码编辑、调试和构建功能。
4. **qmake**:Qt的构建系统,用于生成Makefile,简化项目配置和编译过程。
5. **Qt应用的部署策略**:除了使用Linuxdeployqt,还可以采用其他方法,如使用静态链接Qt库、使用AppImage格式等,每种方法都有其优缺点,需要根据具体需求选择。
Linuxdeployqt是Qt开发者在Linux环境下必备的工具之一,它简化了应用程序的部署过程,使得Qt应用能在未安装Qt环境的系统上运行。通过研究其源码,开发者不仅可以学习到Qt部署的细节,还能了解到开源社区的协作模式和软件开发的最佳实践。

在宇宙玩电脑
- 粉丝: 37
最新资源
- 区块链技术下供应链节点间信任问题研究.docx
- 网络安全产业布局深化细化-工业信息安全形势严峻.docx
- 数字图像处理课程设计方案报告王芳.doc
- 经济法视角下大学生网络订餐食品安全问题思考.docx
- 电力自动化继电保护安全管理的分析.doc
- 关于网络环境下初中语文教学模式的探索.docx
- 代建制是工程项目管理全面发展的重要商机.docx
- 中职《计算机应用基础》教学实践的探讨.docx
- 农村电商人才缺乏背景下的非涉农中职学校电子商务专业教学改革探究.docx
- 基于大数据分析的教师培训质量评估探索.docx
- 大型Web项目可用性提升优化.pptx
- 自动化技术在电子信息工程中的分析.docx
- plc控制投币式全自动洗衣机.doc
- 区块链对数字经济高质量发展的影响因素研究.docx
- 机械制图与CAD基础.ppt
- 计算机专业英语教学实践及改革探讨.docx