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
1 2 3 4 5 6 7 8 | -- 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
有输出信息:成功!
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性