代码改变世界

qt程序打包部署

2023-06-21 14:27  @学无止境  阅读(42)  评论(0编辑  收藏  举报

参考:

https://blog.csdn.net/zyhse/article/details/106381937/
https://blog.csdn.net/sksukai/article/details/107325930
https://blog.csdn.net/langshuibaren/article/details/119971279

linuxdeployqt-6-x86_64.AppImage(花我4块钱下载的) 分享地址

https://pan.baidu.com/s/1noRc7Gtj9rYEYhLHsV5s7Q 提取码:1vde

 

1、在~/.bashrc中添加环境变量

 

export PATH=/opt/Qt5.12.9/5.12.9/gcc_64/bin:$PATH
export LIB_PATH=/opt/Qt5.12.9/5.12.9/gcc_64/lib:$LIB_PATH
export PLUGIN_PATH=/opt/Qt5.12.9/5.12.9/gcc_64/plugins:$PLUGIN_PATH
export QML2_PATH=/opt/Qt5.12.9/5.12.9/gcc_64/qml:$QML2_PATH

 

source ~/.bashrc

 

然后,新建一个文件夹

 

mkdir winp

cd winp

将qt生成的release版本的程序文件(DkClient)和依赖动态库(libhhhorizlineplugin.so)、配置文件(xxx.ini)等文件复制至此文件夹下。

 

2、在winp目录下执行 linuxdeployqt winpro -appimage,会自动引入依赖库

然后,打包压缩当前目录至 winp.tar.gz

3、在目录机器上解压winp.tar.gz,并进入winp目录。

cd winp

4、将动态库文件移至lib目录下,将plugins下的文件移至当前目录下(ubuntu下测试的不用移)

5、连接mysql时,将libqsqlmysql.so(需要release版本的)添加至sqldrivers下,将libmysqlclient.so.18.0.0添加至lib下,并建软链接 libmysqlclient.so.18

6、在~/.bash_profile下添加环境变量LD_LIBRARY_PATH

cat .bash_profile 

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
#QT_QPA_PLATFORM_PLUGIN_PATH=/soft/winp/platforms
LD_LIBRARY_PATH=/soft/winp/lib:$LD_LIBRARY_PATH

export PATH
#export QT_QPA_PLATFORM_PLUGIN_PATH
export LD_LIBRARY_PATH

source  ~/.bash_profile

应该就可以运行./winpro了。