qt linux下编译linuxdeployqt ,进行打包qt程序

一、

sudo apt install patchelf

 

二、

sudo apt-get install camke

 

三、打开.bashrc

1、vim ~/.bashrc

2、添加环境变量(注意自己的qt安装位置)

export LD_LIBRARY_PATH=/usr/local/lib:/home/hywc/Qt5.14.2/5.14.2/gcc_64/lib:$LD_LIBRARY_PATH
export PATH=/home/hywc/Qt5.14.2/5.14.2/gcc_64/bin:$PATH
export QT_PLUGIN_PATH=/home/hywc/Qt5.14.2/5.14.2/gcc_64/plugins:$QT_PLUGIN_PATH
export QML2_IMPORT_PATH=/home/hywc/Qt5.14.2/5.14.2/gcc_64/qml:$QML2_IMPORT_PATH

 

 四、安装git

sudo apt install git

 

五、下载linuxdeployqt

git clone https://github.com/probonopd/linuxdeployqt.git --depth=1


六、修改main.cpp文件

vim linuxdeployqt/tools/linuxdeployqt/main.cpp

else {
        // openSUSE Leap 15.0 uses glibc 2.26 and is used on OBS
        // Ubuntu Xenial (16.04) uses glibc 2.23
        // Ubuntu Bionic (18.04) uses glibc 2.27  ****将这个位置的if注释掉
        /*if (strverscmp (glcv, "2.28") >= 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 (Ubuntu Bionic), which is glibc 2.27.";
            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;
        }*/                                       --终
    }

 

七、进入~/linuxdeployqt/下

cd linuxdeployqt

 

八、执行CMakeLists.txt

cmake CMakeLists.txt

-- Updating excludelist...
CMake Warning at tools/linuxdeployqt/CMakeLists.txt:23 (message):
  Updating excludelist failed, using outdated copy


-- Configuring done
-- Generating done
-- Build files have been written to: /home/hywc/linuxdeployqt     **表示执行成功,如果产生问题,根据问题一个一个解决,可能是找不到qt,qt环境变量没有配置好

 

*** 我的环境变量配置***
export PATH=/home/hywc/Qt5.14.2/5.14.2/gcc_64/bin:$PATH
export LIB_PATH=/home/hywc/Qt5.14.2/5.14.2/gcc_64/lib:$LIB_PATH
export PLUGIN_PATH=/home/hywc/Qt5.14.2/5.14.2/gcc_64/plugins:$PLUGIN_PATH
export QML2_PATH=/home/hywc/Qt5.14.2/5.14.2/gcc_64/qml:$QML2_PATH
export QT5_DIR=/home/hywc/Qt5.14.2/5.14.2/gcc_64/lib/cmake/Qt5:$QT5_DIR
export LD_LIBRARY_PATH=/usr/local/lib:/home/hywc/Qt5.14.2/5.14.2/gcc_64/lib

 

九、继续在~/linuxdeployqt目录下

执行:make

[100%] Built target linuxdeployqt   //表示成功

 

十、生成的可执行文件在linuxdeployqt/tools/linuxdeployqt目录下

执行:./linuxdeployqt

最后位置产生:documentation for more information about deployment on Linux. 表示成功

 

十一、复制可执行文件linuxdeployqt 到/usr/local/bin下

进入:tools/linuxdeployqt下

执行:sudo cp linuxdeployqt /usr/local/bin/

 

十二、测试

退到:cd ~

执行:linuxdeployqt

有输出信息:成功!

 

posted @ 2023-03-24 16:31  雾枫  阅读(1527)  评论(0编辑  收藏  举报