linux下Qt使用LinuxDeployqt打包

linux下Qt使用LinuxDeployqt打包

环境: Ubuntu2204

一、直接使用linuxDeployqt程序打包

1.下载linuxdeployqt-continuous-x86_64.AppImage

https://github.com/probonopd/linuxdeployqt/releases

2.修改名称和权限

mv linuxDeployqt-x86_64.AppImage linuxdeployqt
sudo chmod +x linuxdeployqt

3.配置QT环境变量

export PATH=/opt/qt5.12/5.12.12/gcc_64/bin:$PATH
export LIB_PATH=/opt/qt5.12/5.12.12/gcc_64/lib:$LIB_PATH
export PLUGIN_PATH=qt5.12/5.12.12/gcc_64/plugins:$PLUGIN_PATH
export QML2_PATH=qt5.12/5.12.12/gcc_64/qml:$QML2_PATH

4. 将Qt应用拷贝到某个目录下

使用linuxDeployqt命令打包

linuxDeployqt xxx -appimage

xxx: 改为自己要打包的应用名称

输出
Error: The host system is too new.
原因

ubuntu版本太新

二、另一个方法下载linuxDeployqt源码并编译

1. 下载tar源码, 解压

https://github.com/probonopd/linuxdeployqt/releases
https://download.csdn.net/download/LiHong333/88565443

2. 编译源码

在linuxdeployqt-continuous/tools/linuxdeployqt目录下找到main.cpp文件,修改版本判断,将下面的代码屏蔽;

//if (strverscmp (glcv, "2.32") >= 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 supported mainstream distribution (Ubuntu Focal Fossa), which is glibc 2.31.";
        //    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;
        //}

3. 在linuxdeployqt-continuous目录下编译

/linuxdeployqt-continuous$ qmake
/linuxdeployqt-continuous$ make
cd src/ && ( test -e Makefile || /opt/qt5.12/5.12.12/gcc_64/bin/qmake -o Makefile /linuxdeployqt-continuous/src/src.pro ) && make -f Makefile 
make[1]: Entering directory '/linuxdeployqt-continuous/src'
make[1]: Nothing to be done for 'first'.

你可能感兴趣的:(Qt,linuxDeployqt,linux,qt)