installing uclibc runtime on target system
Rob Landley
rob at landley.net
Sun Apr 18 21:31:41 UTC 2010
On Sunday 18 April 2010 12:57:04 Jason Curl wrote:
> On 18/04/2010 18:47, Matthias Hofmann wrote:
> > Hello,
> >
> > i use a uclibc crosscompiler toolchain to build programs for my target
> > system which is based on embedded linux, but my programs are not running
> > properly there, especially shared libraries.
> >
> > how to install uclibc on my embedded target system?
>
> I just copied the files across that I needed into /lib. You might not
> have copied all files that you need across. I've got a Perl script I
> wrote 3 years ago to tell me what dependencies I have.
Oh, I forgot:
# Recursively grab an executable and all the libraries needed to run it.
# Source paths beginning with / will be copied into destpath, otherwise
# the file is assumed to already be there and only its library dependencies
# are copied.
mkchroot()
{
[ $# -lt 2 ] && return
echo -n .
dest=$1
shift
for i in "$@"
do
[ "${i:0:1}" == "/" ] || i=$(which $i)
[ -f "$dest/$i" ] && continue
if [ -e "$i" ]
then
d=`echo "$i" | grep -o '.*/'` &&
mkdir -p "$dest/$d" &&
cat "$i" > "$dest/$i" &&
chmod +x "$dest/$i"
else
echo "Not found: $i"
fi
mkchroot "$dest" $(ldd "$i" | egrep -o '/.* ')
done
}
That's a bash function I wrote back in 2006. The first argument is the
directory to create a new chroot in, the remaining arguments are all the
binaries you need it to copy into the target (along with their shared
libraries, and the shared libraries those link to, and so on).
There's a version of this in the busybox testsuite/testing.sh directory, but
Cristian Ionescu-Idbohrn broke it in 2008 by replacing a bash-ism with a NOP
replacement (for no apparent reason, commit 2dea01ca11b08), and it doesn't
look like Denys has actually tested it since. Oh well...
The above is the version I checked in back when it was working.
The downside of that is you need an existing working system (with ldd, which
it recursively calls to do its thing). This function just copies the minimal
set of shared libraries the executables you list actually need from the host
you're running it on into the new chroot.
Rob
--
Latency is more important than throughput. It's that simple. - Linus Torvalds
More information about the uClibc
mailing list