www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/04/02/19:54:02

From: j DOT aldrich6 AT genie DOT com
Message-Id: <199604030027.AA059661256@relay1.geis.com>
Date: Tue, 2 Apr 96 23:56:00 UTC 0000
To: djgpp AT delorie DOT com
Mime-Version: 1.0
Subject: Re:ERROR MSG: junk.c(.text+0xf

Reply to message 8212579    from JABROWN AT UNIX. on 04/02/96 11:02AM


>gcc -lpc -Wall -pedantic junk.c -o junk
>
>... I get this error message:
>
>junk.c(.text+0xfd): undefined reference to 'getche'

ld links files in the order it finds them on the command line.  When it sees
'-lpc' as the first command, it looks at the library, but doesn't link anything
because it doesn't have anything to link it to (it hasn't found your program
yet).  To correct this, just put the link command at the END of the command
line, like so:

gcc -Wall -pedantic junk.c -o junk -lpc

Look in the INFO docs for 'gcc' and 'ld'.  It tells you everything you need to
know about the differences between one-pass and two-pass linkers.  I made
the same mistake a few times before I got it figured out.

John

- Raw text -


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