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

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

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

$ linuxdeployqt -v

linuxdeployqt  (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" ]; then
    echo "Usage: $0 <path-to-executable>"
    exit 1
fi

EXECUTABLE=$1
DEST_DIR="deploy"
LIB_DIR="$DEST_DIR/libs"

# 创建目标目录
mkdir -p "$LIB_DIR"

# 使用 ldd 查找可执行文件的依赖库
ldd $EXECUTABLE | grep "=> /" | awk '{print $3}' | while read -r lib; do
    echo "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; do
    patchelf --set-rpath '$ORIGIN' "$lib"
done

echo "Deployment completed. Check the $DEST_DIR directory."

相关推荐

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

    2024-07-17 07:32:03       22 阅读
  2. Linux打包Qt-使用linuxDeployQt+appimageTool

    2024-07-17 07:32:03       50 阅读
  3. Ubuntu22.04打包发布Qt5.15应用程序的方法

    2024-07-17 07:32:03       53 阅读
  4. Ubuntu/WSL生产密钥脚本

    2024-07-17 07:32:03       43 阅读
  5. Ubuntu使用Caddy安装部署LXD

    2024-07-17 07:32:03       37 阅读
  6. Ubuntu应用软件安装

    2024-07-17 07:32:03       74 阅读
  7. C#控制台应用程序自动发布Bat脚本

    2024-07-17 07:32:03       43 阅读
  8. ubuntu一键安装docker和docker-compose应用脚本

    2024-07-17 07:32:03       32 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-17 07:32:03       70 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-17 07:32:03       74 阅读
  3. 在Django里面运行非项目文件

    2024-07-17 07:32:03       62 阅读
  4. Python语言-面向对象

    2024-07-17 07:32:03       72 阅读

热门阅读

  1. 我们来科普以下vue中v-show 和v-if区别

    2024-07-17 07:32:03       25 阅读
  2. Day 10.08函数作业答案·二

    2024-07-17 07:32:03       23 阅读
  3. 面试题 30. 包含 min 函数的栈

    2024-07-17 07:32:03       26 阅读
  4. OpenResty使用Lua笔记

    2024-07-17 07:32:03       26 阅读
  5. Springboot定义阿里云oss工具类

    2024-07-17 07:32:03       25 阅读
  6. 入门 git

    2024-07-17 07:32:03       22 阅读
  7. IPython 的 %history -p 命令:探索命令行历史的秘籍

    2024-07-17 07:32:03       30 阅读
  8. [NOIP2006 提高组] 作业调度方案(含代码)

    2024-07-17 07:32:03       20 阅读
  9. OpenSearch 第三方IoT设备日志分析

    2024-07-17 07:32:03       32 阅读
  10. Photoshop

    Photoshop

    2024-07-17 07:32:03      20 阅读
  11. Github07-16 Python开源项目日报 Top10

    2024-07-17 07:32:03       24 阅读