当前位置: 首页> 房产> 建材 > ubuntu下发布应用,ldd脚本代替linuxdeployqt

ubuntu下发布应用,ldd脚本代替linuxdeployqt

时间:2025/7/12 3:20:43来源:https://blog.csdn.net/WMX843230304WMX/article/details/140480314 浏览次数:0次

ubuntu下发布应用,ldd脚本代替linuxdeployqt

主机环境 ubuntu22.04
下载linuxdeployqt 发现运行不起来,glbc版本不匹配

$ linuxdeployqt -vlinuxdeployqt  (commit 8cb9438), build 67 built on 2024-07-09 18:22:04 UTC
ERROR: The host system is too new.
Please run on a system with a glibc version no newer than what comes with the oldest
currently supported mainstream distribution (Ubuntu Focal Fossa), which is glibc 2.31.
This is so that the resulting bundle will work on most still-supported Linux distributions.
For more information, please see
https://github.com/probonopd/linuxdeployqt/issues/340$ ldd --version
ldd (Ubuntu GLIBC 2.35-0ubuntu3.8) 2.35
Copyright (C) 2022 自由软件基金会。
这是自由软件;复制本软件需满足的条件请参见源代码。本软件不提供任何
品质保证;甚至不保证适销性或是适用于某种特定用途。
由 Roland McGrath 和 Ulrich Drepper 编写。

所以用ldd脚本代替:

deployapp.sh

#!/bin/bash# 检查是否提供了可执行文件路径
if [ -z "$1" ]; thenecho "Usage: $0 <path-to-executable>"exit 1
fiEXECUTABLE=$1
DEST_DIR="deploy"
LIB_DIR="$DEST_DIR/libs"# 创建目标目录
mkdir -p "$LIB_DIR"# 使用 ldd 查找可执行文件的依赖库
ldd $EXECUTABLE | grep "=> /" | awk '{print $3}' | while read -r lib; doecho "Copying $lib to $LIB_DIR"cp "$lib" "$LIB_DIR"
done# 拷贝可执行文件到目标目录
cp "$EXECUTABLE" "$DEST_DIR"# 使用 patchelf 修补可执行文件和库的路径
echo "Patching executable and libraries..."
patchelf --set-rpath '$ORIGIN/libs' "$DEST_DIR/$(basename $EXECUTABLE)"find "$LIB_DIR" -type f -name "*.so*" | while read -r lib; dopatchelf --set-rpath '$ORIGIN' "$lib"
doneecho "Deployment completed. Check the $DEST_DIR directory."
关键字:ubuntu下发布应用,ldd脚本代替linuxdeployqt

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: