Mail Archives: djgpp/1996/08/07/14:10:15
macleod AT ritz DOT mordor DOT com (J.J. Pierson ) wrote:
>OK. I was playing around with the gcc compiler and ld linker. I figured
>I'd try to compile to an object file and then link it separately.
>I compiled like this:
>"gcc -c proto.c"
>I got a proto.o file.
>I then tried:
>"ld proto.o -lc"
>It can't find the file -lc...
>I then tried:
>"ld proto.o -L d:\djgpp\lib\ -lc"
>It finds the file, but I then get errors such as:
>* d:/djgpp/bin/ld.exe: warning: cannot find entry symbol start; defaulting
>* to 000010a8
>*
>* malloc.c(.text+0x1e): undefined reference to `__sbrk'
>*
You need to link it with a few more things. Like crt0.o (I think
that's what it's called) in the lib directory... I think __sbrk is the
sbrk helper in there. crt0 also contains the entry symbol, which is
the routine that calls main()! Without it, not a lot will happen...
Try somethign like:
ld proto.o d:\djgpp\lib\crt0.o -lc -lgcc
libgcc, I seem to remember, defines a few internal helper functions
the compiler uses invisibly.
>I have no idea why it's not linking correctly, esp. since if I just do
>"gcc proto.c", it will compile and link fine.
gcc includes those funnies automagically. It uses the /lib/specs file
to decide what to do. There's a prize if you can understand the linker
section :-/ (not really...)
Regards,
ABW
--
I have become... Comfortably numb...
Alaric B. Williams Internet : alaric AT abwillms DOT demon DOT co DOT uk
<A HREF="http://www.hardcafe.co.uk/Alaric/">http://www.hardcafe.co.uk/Alaric/</A>
- Raw text -