LinuxSA Mailing list archives

Index: [thread] [date] [subject] [author]
  From: Glen Turner <glen.turner@adelaide.edu.au>
  To  : Darryl Ross <darryl@bachblue.com.au>
  Date: Tue, 06 Apr 1999 23:30:59 +0930

Re: Compiling Problem

Darryl Ross wrote:

> This isn't a Linux specific question, but I don't really know who else to
> ask. A friend of mine doing the same programming subject as me gets the
> following error when he tries to compile one of the practicals we have to
> do:
> 
> Undefined                       first referenced
>  symbol                             in file
> main
> /home/lux/b/itu/gnu/gcc/lib/gcc-lib/sparc-suris2.4/2.6.3/crt1.o
> ld: fatal: Symbol referencing errors. No output written to a.out
> 
> However, when he sends the source to me and I compile it on my account, it
> works fine. But then when I send it back it gives the same error.


The code doesn't appear to contain a main() function!

crt0.c is the program that initialises the C enviroment
(setting up argc, argv, errno and so on), and when it
is done, calls the function

  int main(int argc, char *argv[], char *envp[])

"ld" is the link-loader.  It's job is to resolve all
symbols (and function names are symbols) into addresses.

The error message says that the linker has seen main()
called in crt.o, but can't find main()'s definition
(and thus its address) in any of the other code it has
been asked to link together.


To summarise, every C program you write needs a main()
function -- the function where the program starts and,
usually, ends.

Cheers,
Glen

PS: If this isn't the problem, then please post the
    full compile and link command being used.

-- 
 Glen Turner                               Network Specialist
 Tel: (08) 8303 3936          Information Technology Services
 Fax: (08) 8303 4400         The University of Adelaide  5005
 Email: glen.turner@adelaide.edu.au           South Australia

-- 
Check out the LinuxSA web pages at http://www.linuxsa.org.au/
To unsubscribe from the LinuxSA list:
  mail linuxsa-request@linuxsa.org.au with "unsubscribe" as the subject


Index: [thread] [date] [subject] [author]
Return to the LinuxSA Mailing List Information Page