www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/11/07/12:49:56

Date: Sun, 7 Nov 1999 17:38:41 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Alexander Russell <alexad3 AT uniserve DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: link error, undefined reference to `write'
In-Reply-To: <941922425.476047@neptune.uniserve.ca>
Message-ID: <Pine.SUN.3.91.991107173313.12805i-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Sat, 6 Nov 1999, Alexander Russell wrote:

> ld -Lc:\\djgpp\\lib c:\\djgpp\\lib\\crt0.o database.o crossw.o
> words.o -lm -lc -
> lgcc -o CROSSW.EXE
> c:\djgpp\lib/libgcc.a(_new_handler.o): In function `__default_new_handler':
> libgcc2.c(.text+0x4d): undefined reference to `write'
> make.exe: *** [CROSSW.EXE] Error 1

It is generally not recommended to call `ld' directly, because you can 
easily miss the right arguments or their order and get errors.  It is 
much easier to invoke gcc for this.

If you absolutely MUST call `ld' directly, look at the file lib/specs for 
the exact arguments gcc passes to it, and do the same.  If you cannot 
figure out the cryptic syntax of lib/specs, invoke gcc with -v on some 
simple program and you will see how it invokes `ld'.

> Am I missing a lib in the link line?

One problem is that you miss the djgpp.djl linker script.  Another 
problem is that you need to say "-lgcc -lc -lgcc" (yes, -lgcc twice).

- Raw text -


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