delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/12/04:48:54.1

From: "Stefan Viljoen" <rylan AT intekom DOT co DOT za>
To: <djgpp AT delorie DOT com>
Subject: Re: A Linking problem
Date: Fri, 11 Jun 1999 09:31:48 +0300
X-MSMail-Priority: Normal
X-Priority: 3
X-Mailer: Microsoft Internet Mail 4.70.1155
MIME-Version: 1.0
Message-Id: <E10sjSw-0005Hf-00@smtp.intekom.co.za>
Reply-To: djgpp AT delorie DOT com

----------
> From: Frank Bean <rizim AT hotmail DOT com>
> Newsgroups: comp.os.msdos.djgpp
> Subject: A Linking problem
> Date: Thursday, June 03, 1999 4:17 PM
> 
> 
> Hello,
> I am have a bit of trouble linking my *.o files. I am trying to port a
mud 
> to run at dos. The *.c files compile fine, but when I type "gcc -o 
> filename.exe *.o" I get a long list of things that say undefined
reference, 
> and it seems to be all of the functions. At the end of the linking
process 
> there is a message....

Your problem seems to be that you cannot use wildcards ("*.o*) on the GCC
commandline - I think! Rather create a makefile (take a look at LAMETRO on
WWW page if you do not know how) and assign all the object filenames in the
way I did in LAMETRO's makefile. This  automatically feeds all the .O
filenames to GCC AT ONCE at the correct time and enables you to compile the
program (I think!)
 
> "c:\djgpp\lib\libc.a(crt1.o)(.text+0x446):crt1.c:undefined reference to 
> 'main'.

This means that the main program function is not present - take a look at
the make file for LAMETRO - you need to define a source file that has the
"main" function in it. What happens above is that GCC obliging compiles,
but when it comes time to create the .EXE it can't find the .O file with
the "main()" function - it thus complains with the text+0x446 error message
that it cannot find main. It is considered an "underfined reference" since
it is "referenced" by default. Remember from basic C class that when a C
program starts, it always starts at the top of main() - if it cannot find
it - BLOOEY! The compiler stops with a link time error.
 
> thank you very much!!

No problem!

This message courtesy of
RylanNet rylan AT intekom DOT co DOT za
http://home.intekom.com/rylan/
--
StarWars for ever!.

- Raw text -


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