Xref: news2.mv.net comp.os.msdos.djgpp:6718 From: Thomas Demmer 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: NNTP-Posting-Host: bvb.lstm.ruhr-uni-bochum.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: "J.J. Pierson" 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 * *************************************************************