使用AppImage打包名为irSync的QT应用程序的重新生成步骤
应用程序名为myApp icon名为:logo.png
1.创建一个名为PacketAppDir的文件夹。
2.准备myApp.desktop文件,文件内容为:
[Desktop Entry]
Version=1.0
Type=Application
Name=myApp
Exec=myApp
Icon=logo
Categories=Utility;
3.准备脚本文件AppRun,内容如下
#!/bin/bash
# 设置应用程序的环境变量
export LD_LIBRARY_PATH=$APPDIR/usr/lib:$LD_LIBRARY_PATH
export QT_PLUGIN_PATH=$APPDIR/usr/plugins
exec $APPDIR/usr/bin/myApp "$@"
4.在PacketAppDir文件夹中创建如下目录结构
PacketAppDir/
|----usr/
| |-------bin/
| |___myApp
| |-------plugins/将需要用到的插件放入此处
| |-------lib/将需要用到的类库放入此处
| |-------share/
| |___applications/
| |___myApp.desktop
| |___icons/
| |___logo.png
需要用到的类库 插件用ldd命令列出:
举例:
运行:ldd myApp
显示:linux-vdso.so.1 (0x00007ffef795c000)
libdl.so.2 => /home/drs/irSyncPacket/usr/bin/./../lib/libdl.so.2 (0x00007f9c370c6000)
libQt5Widgets.so.5 => /usr/local/qt-qt-5.15.2/lib/libQt5Widgets.soexport QT_PLUGIN_PATH=$APPDIR/usr/plugins.5 (0x00007f9c36a4d000)
libQt5Gui.so.5 => /usr/local/qt-qt-5.15.2/lib/libQt5Gui.so.5 (0x00007f9c3641d000)
libQt5Network.so.5 => /usr/local/qt-qt-5.15.2/lib/libQt5Network.so.5 (0x00007f9c36286000)
libQt5Sql.so.5 => /usr/local/qt-qt-5.15.2/lib/libQt5Sql.so.5 (0x00007f9c36249000)
libQt5Core.so.5 => /usr/local/qt-qt-5.15.2/lib/libQt5Core.so.5 (0x00007f9c35cf3000)
libGL.so.1 => /home/drs/irSyncPacket/usr/bin/./../lib/libGL.so.1 (0x00007f9c35a3e000)
libpthread.so.0 => /home/drs/irSyncPacket/usr/bin/./../lib/libpthread.so.0 (0x00007f9c35a15000)
列表中涉及到的库都需要放入usr/lib目录中进行打包
5.打开终端,切换到irSyncPacket.AppDir文件夹所在的目录。
8.运行以下命令将应用程序打包为AppImage:
chmod +x AppRun
chmod +x myApp
/home/drs/下载/linuxdeploy-x86_64.AppImage --appdir /home/drs/PacketAppDir --output appimage
9.打包过程完成后,将会在当前目录生成一个名为PacketAppDir-x86_64.AppImage的文件。
10.运行AppImage:
给AppImage文件添加可执行权限:
chmod +x PacketAppDir-x86_64.AppImage
运行应用程序:
./PacketAppDir-x86_64.AppImage
执行打包后的AppImage出现错误
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, webgl, xcb.
已放弃
设置 export QT_DEBUG_PLUGINS=1 再次执行,出现详细错误信息
QLibraryPrivate::loadPlugin failed on "/tmp/.mount_irSyncsNMCZg/usr/plugins/platforms/libqxcb.so" : "Cannot load library /tmp/.mount_irSyncsNMCZg/usr/plugins/platforms/libqxcb.so: (libxcb-util.so.1: 无法打开共享对象文件: 没有那个文件或目录)"
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
从QT安装目录/usr/local/Qt-5.15.2中找到libqxcb.so,在目录/usr/local/Qt-5.15.2/plugins/platforms中,复制platforms目录下全部文件到/usr/plugins下,重新打包,完成!
11.创建myApp.sh文件,用于双击运行
文件内容:
#!/bin/bash
APPIMAGE_PATH=/home/drs/下载/PacketAppDir-x86_64.AppImage文章来源:https://www.toymoban.com/news/detail-473393.html
cd "$(dirname "$APPIMAGE_PATH")"
#执行 AppImage文件
"./$(basename "$APPIMAGE_PATH")"文章来源地址https://www.toymoban.com/news/detail-473393.html
到了这里,关于使用linuxdeploy-x86_64.AppImage打包QT应用程序的步骤的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!