method to solve problem of undefined reference to 'main '

> /usr/lib/gcc/i386-redhat-linux/4.0.0/../../../crt1.o(.text+0x18): In
> function `_start':
> : undefined reference to `main'
> collect2: ld returned 1 exit status


Exactly what the error message tells you: there's no main() function.
Actually, this is an error message from the linker that tries to
assenmble the final executable. And during that it finds that there's
no main() function in any of the object files it's linking together
to create the program. Since you don't tell mnore about when that
happens my best guess at the moment is that you actually only want to
compile one of a number of source files into an object file but not
already link. This, in turn, can happen if you call gcc, forgetting
about the '-c' option - without this option gcc tries not only to
compile, but also to link the program.

你可能感兴趣的:(function,object,gcc,File,reference,linker)