检查依赖关系
检查当前目录下的动态库的相关依赖是否有缺失
#!/bin/bash
# 红色文本的 ANSI 转义码
RED='\033[0;31m'
# 重置颜色
NC='\033[0m'
# 获取脚本的当前目录
WORKING_DIR=$(pwd)
echo "Working directory: $WORKING_DIR"
# 遍历当前脚本目录及其子目录下的所有 .so 文件
find "$WORKING_DIR" -type f -name "*.so*" | while read so_file; do
echo "Found .so file: $so_file" # Debugging output
if [ -f "$so_file" ]; then
echo "Checking dependencies for: $so_file"
# 使用 ldd 检查依赖关系,标记未找到的依赖项为红色
ldd "$so_file" | grep "not found" | while read line; do
echo -e "${RED}$line${NC}"
sleep 1
done
echo "---------------------------------"
fi
done