From: eplmst AT lu DOT erisoft DOT se (Martin Stromberg) Newsgroups: comp.os.msdos.djgpp Subject: Re: link error, undefined reference to `write' Date: 7 Nov 1999 15:09:18 GMT Organization: Ericsson Erisoft AB, Sweden Lines: 51 Message-ID: <8044mu$gve$3@antares.lu.erisoft.se> References: <941922425 DOT 476047 AT neptune DOT uniserve DOT ca> NNTP-Posting-Host: propus-144.lu.erisoft.se X-Newsreader: TIN [version 1.2 PL2] To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Alexander Russell (alexad3 AT uniserve DOT com) wrote: : the make file: : --------------- : CC = gcc : link = ld : CFLAGS = -O -c : LFLAGS = -Lc:\\djgpp\\lib c:\\djgpp\\lib\\crt0.o : LFLAGS2 = -lm -lc -lgcc -o : OBJECTS = database.o crossw.o words.o : TARGET = CROSSW.EXE : $(TARGET) : $(OBJECTS) : $(link) $(LFLAGS) $(OBJECTS) $(LFLAGS2) $(TARGET) : %.o : %.cpp : $(CC) $(CFLAGS) $< : ------------- : the error : 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 : Am I missing a lib in the link line? Wrong order? : The code uses fprintf, putc, putch fwrite, fopen, fclose : Installed djgpp from: : bnu281b.zip : djdev202.zip : gcc281.zip : gpp281b.zip : Thanks for any help, clues. 1. Try letting gpp (or gxx) do the linking: "link = gpp LFLAGS = LFLAGS2 = " and see if it works. If it does, add "-v" to the flags to see how gcc handled the order of libraries. 2. Why do you not use "-O2" for optimisation? Oldfield, QE2, MartinS