看了些许资料,在PC上可以用ldd查看程序的依赖库文件,但是交叉编译环境就没法查看了,查了查arm-linux-readelf的资料,找到了个实现arm-linux-ldd的方法。假设你的arm-linux-tools在目录/opt/arm-linux-tools,执行下面脚本:
1. gedit /opt/arm-linux-tools/bin/arm-linux-ldd &
输入以下脚本:
#! /bin/bash
function FindDep()
{
for i in $*; do
dependfile=`$pathname/arm-linux-readelf -a $i | gawk '/Shared library/{print $5}' | sed "s//[/|/]//g"`
if [ ${#dependfile} -gt 0 ]; then
Solver ${dependfile}
fi
done
}
function Solver()
{
for i in $*; do
bFound=0
for j in ${tmpArr[@]}; do
if [ $j = $i ]; then
bFound=1
break
fi
done
if [ $bFound -eq 0 ]; then
bRepeat=0
effectFile=
tmpArr[${#tmpArr[*]}]=$i
allFile=`find $gccPath | grep "$i$"`
if [ ${#allFile} -eq 0 ]; then
echo "$i -> "
else
for j in $allFile; do
if [ $bRepeat -eq 0 ]; then
bRepeat=1
effectFile=$j
echo "$i -> $j"
else
echo "${i//[A-Z,a-z,0-9,.,/+,/-,_]/ } -> $j"
fi
done
fi
link=`ls -l $effectFile | gawk '//->/{print $10}'`
if [ ${#link} -ne 0 ]; then
Solver $link
fi
FindDep $effectFile
fi
done
}
pathname=$0
if [ ${pathname: 0: 1} = "." ]; then
path=$PWD
if [ ${path: ${#path}-1: 1} = "/"]; then
pathname=$(dirname ${path}${pathname})
else
pathname=$(dirname ${path}/${pathname})
fi
else
pathname=$(dirname ${pathname})
fi
gccPath=`find $(dirname ${pathname})/arm-* | grep "/lib$"`
gccPath="$gccPath $extPath"
for i in $*; do
if [ ${i: 0: 2} = "-L" -o ${i: 0: 2} = "-l" ]; then
gccPath="$gccPath ${i: 2: ${#i}-2}"
fi
done
for i in $*; do
if [ ${i: 0: 2} != "-L" -a ${i: 0: 2} != "-l" ]; then
tmpArr=()
echo "dependence of $i is:"
FindDep $i
echo
fi
done
2. chmod 755 /opt/arm-linux-tools/bin/arm-linux-ldd
搞定,现在可以使用arm-linux-ldd查看交叉编译文件的依赖库文件了。在我机子上(Ubuntu 10.04+arm linux 4.5.1 + Qt Embbeded 4.7.1):
执行 /opt/arm-linux-tools/bin/arm-linux-ldd -l/opt/QtEmbedded-4.7.1/lib -l/opt/tslib/lib /opt/QtEmbedded-4.7.1/demos/embeddeddialogs/embeddeddialogs /opt/QtEmbedded-4.7.1/demos/textedit/textedit, 输出:
dependence of /opt/QtEmbedded-4.7.1/demos/embeddeddialogs/embeddeddialogs is:
libQtGui.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtGui.so.4
libQtGui.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtGui.so.4.7.1
libQtNetwork.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtNetwork.so.4
libQtNetwork.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtNetwork.so.4.7.1
libQtCore.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtCore.so.4
libQtCore.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtCore.so.4.7.1
libpthread.so.0 -> /opt/arm-linux-tools/arm-linux/lib/libpthread.so.0
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libpthread.so.0
libpthread-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libpthread-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libpthread-2.11.so
libc.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libc.so.6
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libc.so.6
libc-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libc-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libc-2.11.so
ld-linux.so.2 -> /opt/arm-linux-tools/arm-linux/lib/ld-linux.so.2
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/ld-linux.so.2
ld-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/ld-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/ld-2.11.so
libdl.so.2 -> /opt/arm-linux-tools/arm-linux/lib/libdl.so.2
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libdl.so.2
libdl-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libdl-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libdl-2.11.so
librt.so.1 -> /opt/arm-linux-tools/arm-linux/lib/librt.so.1
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/librt.so.1
librt-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/librt-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/librt-2.11.so
libstdc++.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libstdc++.so.6
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libstdc++.so.6
libstdc++.so.6.0.14 -> /opt/arm-linux-tools/arm-linux/lib/libstdc++.so.6.0.14
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libstdc++.so.6.0.14
libm.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libm.so.6
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libm.so.6
libm-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libm-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libm-2.11.so
libgcc_s.so.1 -> /opt/arm-linux-tools/arm-linux/lib/libgcc_s.so.1
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libgcc_s.so.1
libts-0.0.so.0 -> /opt/tslib/lib/libts-0.0.so.0
libts-0.0.so.0.1.1 -> /opt/tslib/lib/libts-0.0.so.0.1.1
dependence of /opt/QtEmbedded-4.7.1/demos/textedit/textedit is:
libQtGui.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtGui.so.4
libQtGui.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtGui.so.4.7.1
libQtNetwork.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtNetwork.so.4
libQtNetwork.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtNetwork.so.4.7.1
libQtCore.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtCore.so.4
libQtCore.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtCore.so.4.7.1
libpthread.so.0 -> /opt/arm-linux-tools/arm-linux/lib/libpthread.so.0
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libpthread.so.0
libpthread-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libpthread-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libpthread-2.11.so
libc.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libc.so.6
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libc.so.6
libc-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libc-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libc-2.11.so
ld-linux.so.2 -> /opt/arm-linux-tools/arm-linux/lib/ld-linux.so.2
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/ld-linux.so.2
ld-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/ld-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/ld-2.11.so
libdl.so.2 -> /opt/arm-linux-tools/arm-linux/lib/libdl.so.2
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libdl.so.2
libdl-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libdl-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libdl-2.11.so
librt.so.1 -> /opt/arm-linux-tools/arm-linux/lib/librt.so.1
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/librt.so.1
librt-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/librt-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/librt-2.11.so
libstdc++.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libstdc++.so.6
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libstdc++.so.6
libstdc++.so.6.0.14 -> /opt/arm-linux-tools/arm-linux/lib/libstdc++.so.6.0.14
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libstdc++.so.6.0.14
libm.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libm.so.6
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libm.so.6
libm-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libm-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libm-2.11.so
libgcc_s.so.1 -> /opt/arm-linux-tools/arm-linux/lib/libgcc_s.so.1
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libgcc_s.so.1
libts-0.0.so.0 -> /opt/tslib/lib/libts-0.0.so.0
libts-0.0.so.0.1.1 -> /opt/tslib/lib/libts-0.0.so.0.1.1
执行 extPath="/opt/QtEmbedded-4.7.1/lib /opt/tslib/lib" /opt/arm-linux-tools/bin/arm-linux-ldd /opt/QtEmbedded-4.7.1/demos/embeddeddialogs/embeddeddialogs /opt/QtEmbedded-4.7.1/demos/textedit/textedit, 输出:
dependence of /opt/QtEmbedded-4.7.1/demos/embeddeddialogs/embeddeddialogs is:
libQtGui.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtGui.so.4
libQtGui.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtGui.so.4.7.1
libQtNetwork.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtNetwork.so.4
libQtNetwork.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtNetwork.so.4.7.1
libQtCore.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtCore.so.4
libQtCore.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtCore.so.4.7.1
libpthread.so.0 -> /opt/arm-linux-tools/arm-linux/lib/libpthread.so.0
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libpthread.so.0
libpthread-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libpthread-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libpthread-2.11.so
libc.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libc.so.6
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libc.so.6
libc-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libc-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libc-2.11.so
ld-linux.so.2 -> /opt/arm-linux-tools/arm-linux/lib/ld-linux.so.2
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/ld-linux.so.2
ld-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/ld-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/ld-2.11.so
libdl.so.2 -> /opt/arm-linux-tools/arm-linux/lib/libdl.so.2
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libdl.so.2
libdl-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libdl-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libdl-2.11.so
librt.so.1 -> /opt/arm-linux-tools/arm-linux/lib/librt.so.1
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/librt.so.1
librt-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/librt-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/librt-2.11.so
libstdc++.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libstdc++.so.6
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libstdc++.so.6
libstdc++.so.6.0.14 -> /opt/arm-linux-tools/arm-linux/lib/libstdc++.so.6.0.14
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libstdc++.so.6.0.14
libm.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libm.so.6
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libm.so.6
libm-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libm-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libm-2.11.so
libgcc_s.so.1 -> /opt/arm-linux-tools/arm-linux/lib/libgcc_s.so.1
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libgcc_s.so.1
libts-0.0.so.0 -> /opt/tslib/lib/libts-0.0.so.0
libts-0.0.so.0.1.1 -> /opt/tslib/lib/libts-0.0.so.0.1.1
dependence of /opt/QtEmbedded-4.7.1/demos/textedit/textedit is:
libQtGui.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtGui.so.4
libQtGui.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtGui.so.4.7.1
libQtNetwork.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtNetwork.so.4
libQtNetwork.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtNetwork.so.4.7.1
libQtCore.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtCore.so.4
libQtCore.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtCore.so.4.7.1
libpthread.so.0 -> /opt/arm-linux-tools/arm-linux/lib/libpthread.so.0
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libpthread.so.0
libpthread-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libpthread-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libpthread-2.11.so
libc.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libc.so.6
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libc.so.6
libc-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libc-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libc-2.11.so
ld-linux.so.2 -> /opt/arm-linux-tools/arm-linux/lib/ld-linux.so.2
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/ld-linux.so.2
ld-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/ld-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/ld-2.11.so
libdl.so.2 -> /opt/arm-linux-tools/arm-linux/lib/libdl.so.2
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libdl.so.2
libdl-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libdl-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libdl-2.11.so
librt.so.1 -> /opt/arm-linux-tools/arm-linux/lib/librt.so.1
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/librt.so.1
librt-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/librt-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/librt-2.11.so
libstdc++.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libstdc++.so.6
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libstdc++.so.6
libstdc++.so.6.0.14 -> /opt/arm-linux-tools/arm-linux/lib/libstdc++.so.6.0.14
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libstdc++.so.6.0.14
libm.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libm.so.6
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libm.so.6
libm-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libm-2.11.so
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libm-2.11.so
libgcc_s.so.1 -> /opt/arm-linux-tools/arm-linux/lib/libgcc_s.so.1
-> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libgcc_s.so.1
libts-0.0.so.0 -> /opt/tslib/lib/libts-0.0.so.0
libts-0.0.so.0.1.1 -> /opt/tslib/lib/libts-0.0.so.0.1.1
圆满搞定!