www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/08/07/08:46:24

Xref: news2.mv.net comp.os.msdos.djgpp:6718
From: Thomas Demmer <demmer AT LSTM DOT Ruhr-UNI-Bochum DOT De>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: linking question
Date: Fri, 02 Aug 1996 12:39:41 +0100
Organization: Lehrstuhl fuer Stroemungsmechanik
Lines: 49
Message-ID: <3201E8FD.6231@LSTM.Ruhr-UNI-Bochum.De>
References: <DvHGAq DOT G29 AT ritz DOT mordor DOT com>
NNTP-Posting-Host: bvb.lstm.ruhr-uni-bochum.de
Mime-Version: 1.0
To: "J.J. Pierson" <macleod AT onyx DOT interactive DOT net>
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019