On Tue, 29 Mar 2005, Amir Binyamini wrote: > I do not have , under/usr/lib/gcc-lib/, a crt1.o (also not a symlink to > /usr/lib). > So I used the /usr/lib/crt1.o.
this is exactly what i wrote ('strace' told me this short path in its old twisted way ;) ) > I use gcc (GCC) 3.2.2on Red Hat 9 ; the new glibc libs I had built is in > /work/myglibc/lib > when trying, as I understoof from your suggestion,to compile with > gcc -static-nostdlib -L/work/myglibc/lib -lc /usr/lib/crt1.o test.c -o > test > I got: > usr/lib/crt1.o(.text+0xc): In function `_start': > ../sysdeps/i386/elf/start.S:71: undefined reference to `__libc_csu_fini' > /usr/lib/crt1.o(.text+0x11):../sysdeps/i386/elf/start.S:72: undefined > reference > to `__libc_csu_init' > /usr/lib/crt1.o(.text+0x1d):../sysdeps/i386/elf/start.S:81: undefined > reference > to `__libc_start_main' > collect2: ld returned 1 exit status ok, this is a start... > Probing and Googling a bit showed that maybe it should get these symbol from > libc_nonshared , so I tried > gcc -static-nostdlib -L/work/myglibc/lib -lc -lc_nonshared /usr/lib/crt1.o > test.c ah, getting even better... > and (strangely) got the same error. 1. never ever ever specify link flags before specifying the list of object files. don't ask me why - perhaps this is just a habbit. 2. it looks like there's a need to add '-lgcc' after '-lc_nonshared', gcc being libgcc.a found in your compiler's directory. 3. to /usr/lib/crt1.o there's a need to add /usr/lib/crti.o, and for /usr/lib/crtn.o . 4. gcc itself (at least my very old version) also links files named 'crtbegin.o' and 'crtend.o' - no idea what they are for - perhaps to initialize things related to global functoins in libgcc... and i'm having the easy life - i'm just trying to get gcc -static --nostdinc to work with the same glibc that i have on my system. so, give a try(*) with these extras, and see what gives: gcc -static -nostdlib test.c /usr/lib/crt1.o /usr/lib/crti.o \ /usr/lib/crtn.o \ /usr/lib/gcc-lib/i386-redhat-linux/2.96/crtbegin.o \ /usr/lib/gcc-lib/i386-redhat-linux/2.96/crtend.o \ -L/usr/lib -lc -lc_nonshared -lgcc -o test (*) NOTE: replace /usr/lib/gcc-lib/i386-redhat-linux/2.96 to the matching path of the gcc library on your machine. by the way, you chose a dangerous name, 'test' - i assume you're running it as './test', to make sure what runs is your binary, and not /usr/bin/test (i'm writing this mostly for the sake of other readers, who might try doing your little stun in the future based on a logging of this thread :0 ). -- guy "For world domination - press 1, or dial 0, and please hold, for the creator." -- nob o. dy ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]