www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1993/01/05/00:57:54

From: Mark Bergman <bergman AT Panix DOT Com>
Subject: Link order problem
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Date: Tue, 5 Jan 1993 00:19:16 -0500 (EST)

Environment:
	486, 8MB, DV (not DV/X), MKS Kornshell, latest DJGPP release.

I'm pretty clueless about how the order of object files in a makefile
is determined.

For example, I'm trying to "port" (simply recompile) the source to
"agrep" using the DJGPP compiler. I consistently get errors along the
lines of:

	preprocess.o: Undefined symbol _init referenced from text segment
        ^^obj name^^                  ^funct^

Where "obj name" and "funct" change depending on the order that the
object files are listed in the makefile. In this case, the function
init() is defined in a module (follow.o) that is listed after
preprocess.o in the makefile. Switching the two produces more errors of
the same sort, because follow.c depends on functions defined in
preprocess.c. The makefile as distributed produces about 25 errors of
this type.

Defining init() in preprocess.c (either with the same definition found
in follow.c or as an extern) doesn't seem to help--I get the same error
message.

Is there any way to determine the correct order of files in makefile.
Why does it matter, doesn't the linker sort of throw all the functions
into a blender and turn it on?

I'm trying to find out what's wrong w. my DJGCC set up. When I use the
same code, and original makefile (the one that produces ~25 errors on
my home machine) on a Sun, it compiles w/o any problems. Gcc in both
cases. I don't get any error messages at home until the link dies.
Other things compile fine, including other multi-module programs,
however, I have run into this problem before, and solved it by
re-ordering the object listing in the makefile.


-- 
Mark Bergman    (Biker, Stagehand, (former) Unix user support grunt)
718-855-9148

bergman AT panix DOT com
{cmcl2,uunet}!panix!bergman

- Raw text -


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