Mail Archives: djgpp/1996/08/07/08:46:24
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"
>
>[...]
> 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.
Try
redir -e foo gcc -v -o proto.exe proto.c
to see how gcc calls ld. The trick is basically to say
-lc -ldon't remember -lc
One of the ugly consequences that ld is a one pass linker.
On the other hand, you are leaving out at least crt0.o, which is
neccessary, too
Again, have a look at foo. Be scared of what you see. That's
what gcc is for ;-)
gcc -o proto.exe proto.o
is way easier.
--
Ciao
Tom
*************************************************************
* Thomas Demmer *
* Lehrstuhl fuer Stroemungsmechanik *
* Ruhr-Uni-Bochum *
* Universitaetsstr. 150 *
* D-44780 Bochum *
* Tel: +49 234 700 6434 *
* Fax: +49 234 709 4162 *
* Voice/Fax Box: +49 2561 91371 2056 *
* http://www.lstm.ruhr-uni-bochum.de/~demmer *
*************************************************************
- Raw text -