1、新建脚本文件pack.sh SensorMaster.sh
(1)pack.sh
#!/bin/sh
exe="SensorMaster" #你需要发布的程序名称
des="/home/jianwang16/SensorMaster_Proj/build-SensorMaster-Desktop_Qt_5_9_0_GCC_64bit-Release/SensorMaster_Pack/install-pack " #创建文件夹的位置
deplist=$(ldd $exe | awk '{if (match($3,"/")){ printf("%s "),$3 } }')
cp $deplist $des
(2)SensorMaster.sh
SensorMaster.sh 的名称应该和Release版本编译发布的文件相同,在此处我的文件名称是SensorsMaster
#!/bin/sh
appname=`basename $0 | sed s,\.sh$,,`
dirname=`dirname $0`
tmp="${dirname#?}"
if [ "${dirname%$tmp}" != "/" ]; then
dirname=$PWD/$dirname
fi
LD_LIBRARY_PATH=$dirname
export LD_LIBRARY_PATH
$dirname/$appname "$@"
2、给文件赋权限
sudo chmod a+x pack.sh SensorMaster.sh
3、执行pack.sh
./pack.sh
4、可以在输出文件夹中看到已经生成的.so库文件。
5、参考
https://blog.csdn.net/qq_27350133/article/details/83445258