Under Linux using Qt release program linuxdeployqt

I. Introduction

linuxdeployqt qt is packaged tools under Linux, you can copy resources (such as libraries, graphics and plug-ins) used by the application to run the file binary file in the same folder.


Second, the installation linuxdeployqt

To github direct download compiled linuxdeployqt-x86_64.AppImage application files.
image.png
After the download is good, it will be renamed linuxdeployqt, and chmod + x, and then copied to / usr / local / bin /. Then the command line input linuxdelpoyqt -version, see if the installation was successful, if output version information indicates that the installation was successful.

$ chmod +x linuxdeployqt-x86_64.AppImage
$ mv linuxdeployqt-x86_64.AppImage linuxdeployqt
$ mv linuxdeployqt /usr/local/bin
$ linuxdelpoyqt --version
#输出的版本信息
linuxdeployqt 5 (commit 37631e5), build 631 built on 2019-01-25 22:47:58 UTC


Third, configure the environment variables qt

Input terminal vim ~/.bashrccommand, modify the .bashrc file, append the following at the end of the file, which is my /home/zlkj/technology/5.9.7 Qt installation path, instead of everyone using their own path:

#add QT ENV
export PATH=/home/zlkj/technology/5.9.7/gcc_64/bin:$PATH
export LD_LIBRARY_PATH=/home/zlkj/technology/5.9.7/gcc_64/lib:$LD_LIBRARY_PATH
export QT_PLUGIN_PATH=/home/zlkj/technology/5.9.7/gcc_64/plugins:$QT_PLUGIN_PATH
export QML2_IMPORT_PATH=/home/zlkj/technology/5.9.7/gcc_64/qml:$QML2_IMPORT_PATH

Finally, look at the source ~ / .bashrc the shell file to take effect immediately, without having to log out and back.

$ source ~/.bashrc


Fourth, packaged applications

(1) release version running Qt generated executable file, check the "shadow build", so the sample using a build-cleanRobot-Desktop_Qt_5_9_7_GCC_64bit-Release folder cleanRobot executable files;
(2) create a folder, the best name is the name of the executable file, and then copy the executable file cleanRobot under this folder;
(3) the use of linuxdeployqt to package, be sure to add -appimage option, the command is as follows:

$ linuxdeployqt cleanRobot -appimage

The above command execution message appears, do not bother, just create a need to edit your own desktop file:

ERROR: Desktop file missing, creating a default one (you will probably want to edit it)

At this point, put the executable file dynamic libraries dependent files are copied to the folder of.


Fifth, write linux desktop icon to start (optional step)

Qt desktop modify files in the directory. Tips can be modified according to the official ubuntu.
ubuntu desktop files

#-- 全局安装(所有用户可用),将xxx.desktop 复制到/usr/share/applications  
#-- 当前用户可用, 将xxx.desktop 复制到 ~/.local/share/applications 目录即可
#--appName.desktop
[Desktop Entry]
Version=1.0 #app的版本
Name=cleanRobot #app的名字
Comment= this app use for xxx #说明信息 
Exec=/path/to/your/QtApp/cleanRobot #app的执行路径,绝对路径
Icon=/path/to/your/app_icon/cleanRobot.ico #icon 路径,绝对路径
Terminal=false #是否在终端启动,效果自己试一下就知道了
Type=Application
Categories=Utility;Application;


Sixth, write the boot script runApp.sh

Execute the following command to create runApp.sh:

vim runApp.sh

Writes the following:

#!/bin/bash
export LD_LIBRARY_PATH=/app/lib:$LD_LIBRARY_PATH
export QT_PLUGIN_PATH=/app/plugins:$QT_PLUGIN_PATH
export QML2_IMPORT_PATH=/app/qml:$QML2_IMPORT_PATH
./cleanRobot

Give run the boot script runApp.sh add executable permissions:

chmod +x runApp.sh

Now running the boot script, you can start the program, you're done.

Seven expansion

1, on the qt.conf

This document specifies the operating environment qt program that we can use to specify qt.conf running path and the library path qt program. Shown as follows:

# Generated by linuxdeployqt
# https://github.com/probonopd/linuxdeployqt/
[Paths]
Prefix = ./     #程序的运行路径
Libraries =  ./lib  #程序的库路径
Plugins = plugins   #插件路径
Imports = qml
Qml2Imports = qml



Reference:
Use linuxdeployqt, released under linux qt
use linuxdeployqt released Qt program in Linux
Linux under qt packaged release (use linuxdelpoyqt, shell scripts)
[] packaged and released Qt Qt program on ubuntu, we can not rely on Qt environment

Guess you like

Origin www.cnblogs.com/linuxAndMcu/p/11016322.html