qt程序发布linux

发布程序时经常会遇到无法找到库的文件。

解决办法一

vim /etc/ld.so.conf

在最下面加上你的自己的so的路径

执行ldconfig  ,使之生效。

如果找不到某个库,就使用ldd  xxx.so查看此so的依赖项。然后依次添加。

解决办法二(推荐)

编写2个sh脚本,注意文件格式一定是unix(LF)utf8编码。

copy的sh文件xxx_copy.sh,查找依赖库文件并copy到指定目录。文件内容如下:

#!/bin/bash
rm -rf /root/pkg/emcunitcapp

LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH:/usr/local/vcpkg/installed/x64-linux/lib
export LD_LIBRARY_PATH


# 可执行程序名
appname="emcunit_c"
# 目标文件夹
dst="/root/pkg/emcunitcapp"
# 目标文件夹的检测
if [ ! -d $dst ];then
	mkdir -p $dst
fi
# 利用 ldd 提取依赖库的具体路径
liblist=$(ldd $appname | awk '{ if (match($3,"/")){ printf("%s "), $3 } }')
# 拷贝库文件 配置文件和可执行程序到目标文件夹
cp $liblist $dst
cp $appname $dst
cp "emcunit_c_run.sh" $dst
cp "Settings.ini" $dst
cp "qt.conf" $dst
cp -r /opt/Qt5.14.2/5.14.2/gcc_64/plugins/imageformats/ $dst
cp -r /opt/Qt5.14.2/5.14.2/gcc_64/plugins/platforms/ $dst
cp -r /opt/Qt5.14.2/5.14.2/gcc_64/translations/ $dst
# 可执行程序名
platformname="/opt/Qt5.14.2/5.14.2/gcc_64/plugins/platforms/libqxcb.so"
# 利用 ldd 提取依赖库的具体路径
Dependslist=$(ldd $platformname | awk '{ if (match($3,"/")){ printf("%s "), $3 } }')
# 拷贝库文件和可执行程序到目标文件夹
cp $Dependslist $dst

运行脚本xxx_run.sh。运行之前先设置library路径。

#!/bin/bash
export LD_LIBRARY_PATH=/root/pkg/emcunitcapp/
/root/pkg/emcunitcapp/emcunit_c

       root权限下,直接执行xxx_run.sh。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值