linuxdeployqt源码编译与打包

1、安装patchelf、cmake

sudo apt install patchelf
sudo apt install cmake

2、下载 linuxdeployqt源码

终端输入指令:git clone https://github.com/probonopd/linuxdeployqt.git
3、将tools/linuxdeployqt/main.cpp中的下述代码注释掉:

// openSUSE Leap 15.0 uses glibc 2.26 and is used on OBS		
/*
	if (strverscmp (glcv, "2.27") >= 0) {    //注释版本检查
    qInfo() << "ERROR: The host system is too new.";
    qInfo() << "Please run on a system with a glibc version no newer than what comes with the oldest";
    qInfo() << "currently still-supported mainstream distribution (xenial), which is glibc 2.23.";
    qInfo() << "This is so that the resulting bundle will work on most still-supported Linux distributions.";
    qInfo() << "For more information, please see";
    qInfo() << "https://github.com/probonopd/linuxdeployqt/issues/340";
    return 1;
}*/

4、在主linuxdeployqt-continuous/tools/linuxdeployqt目录下CMakeLists.txt添加
在这里插入图片描述

CMAKE_MINIMUM_REQUIRED(VERSION 3.16 FATAL_ERROR)
PROJECT(NEWHELLO)
# ADD_SUBDIRECTORY(src)
set(CMAKE_PREFIX_PATH "/home/start/Qt5.13.2/5.13.2/gcc_64")
set(Qt5_DIR "${CMAKE_PREFIX_PATH}/lib/cmake/Qt5")
set(Qt5Widgets_DIR "${CMAKE_PREFIX_PATH}/lib/cmake/Qt5Widgets")
set(Qt5Network_DIR "${CMAKE_PREFIX_PATH}/lib/cmake/Qt5Network")
set(Qt5LinguistTools_DIR "${CMAKE_PREFIX_PATH}/lib/cmake/Qt5LinguistTools")

5、编译

1、在主linuxdeployqt-continuous/tools/linuxdeployqt目录下输入:
	mkdir buile
2、上述执行完毕后再输入:
	cmake ../
	make
3、生成linuxdeployqt,具体生成路径在:
	linuxdeployqt-continuous/tools/linuxdeployqt/buile下
4、修改为可执行权限
	chmod 777 linuxdeployqt
5、将可执行文件linuxdeployqt拷贝到/usr/local/bin,方便使用
	cp linuxdeployqt /usr/local/bin
6、测试是否安装成功
	linuxdeployqt --version

打包
1、Qt库路径设置到环境变量

vim ~/.bashrc
#add qt env
export PATH=/opt/Qt5.13.0/5.13.0/gcc_64/bin:$PATH
export LIB_PATH=/opt/Qt5.13.0/5.13.0/gcc_64/lib:$LIB_PATH
export PLUGIN_PATH=/opt/Qt5.13.0/5.13.0/gcc_64/plugins:$PLUGIN_PATH
export QML2_PATH=/opt/Qt5.13.0/5.13.0/gcc_64/qml:$QML2_PATH
source ~/.bashrc

然后,对环境变量测试下,是否设置正确

qmake -v

在这里插入图片描述

打包Qt生成执行文件,名为xx

执行命令
	linuxdeployqt xxx -appimage

error: could not start patchelf.

error: make sure it is installed on your $path.

error: error reading rpath with patchelf “libqt5widgets.so” : “”

error: error reading rpath with patchelf “libqt5widgets.so” : “”

这个错误是表明缺少需要的pathchelf工具,直接安装即可解决:

sudo apt install patchelf

然后又出现了下面这个错误:

error: ldd outputline: “libjasper.so.1 => not found”

error: for binary:
“/home/xl/qt5.9.2/5.9.2/gcc_64/plugins/imageformats/libqjp2.so”

error: please ensure that all libraries can be found by ldd. aborting.

这表明缺少了libqjp2.so这个库的。缺什么就装什么:

sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"

sudo apt update

sudo apt install libjasper1 libjasper-dev

在这里插入图片描述
只要输入./应用名称能运行就可以忽略sh: 1: appimagetool: not found

./untitled

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值