Wheels, reinventing. (Was Re: [uClibc] Understanding what the build wrapper does...)

Rob Landley rob at landley.net
Wed Sep 3 23:44:34 MDT 2003


In my continuing efforts to reinvent the wheel (or at least make a gcc command 
line that cross-compiles hello.c against uclibc without the wrapper, so I can 
understand what the heck is going on.)

I got to this point:

---
#/bin/sh

DIR=~/pending/sub
GCCDIR==`gcc -v 2>&1 | head -n 1`
GCCDIR=${GCCDIR:19}
GCCDIR=${GCCDIR:0:$[${#GCCDIR}-6]}
echo $GCCDIR

gcc -nostdlib -L$DIR/lib -Wl,--dynamic-linker,/lib/ld-uClibc.so.0 \
    -Wl,--rpath-link,$DIR/lib -nostdinc -isystem $DIR/usr/include \
    -iwithprefix include $DIR/usr/lib/crti.o $GCCDIR/crtbegin.o \
    $DIR/usr/lib/crt1.o hello.c -lc -lgcc $GCCDIR/crtend.o $DIR/usr/lib/crtn.o

---

$DIR is where I've loopback mounted root_fs-i386 for uClibc-0.9.20, and GCCDIR 
parses out the install path of gcc on the host system so I can explicitly 
tell it where the heck things live.

The above dies with:

/home/landley/pending/sub/usr/lib/crt1.o(.text+0x20): In function `_start':
: undefined reference to `__uClibc_start_main'
collect2: ld returned 1 exit status

I _think_ I've reproduced all the elements of the command line the wrapper 
spit out.  (I've tried changing the -lc -lgcc to -lgcc -lc -lgcc, but it's 
not making a lot of difference.

I also tried simplifying the gcc command line down to:

gcc -nostdlib -L$DIR/lib -Wl,--dynamic-linker,/lib/ld-uClibc.so.0 \
    -Wl,--rpath-link,$DIR/lib -nostdinc -isystem $DIR/usr/include \
    -iwithprefix include $DIR/usr/lib/crt0.o hello.c -lc -lgcc

But it still died with the same error.

Er...  Help?

Rob




More information about the uClibc mailing list