b5b gcc, the GNU compiler Contents|Index|Previous|Next

gcc, the GNU compiler 


When you compile C or C++ programs with gnu C, the compiler quietly inserts a call at the beginning of main to a GCC support subroutine called __main. Normally this is invisible—you may run into it if you want to avoid linking to the standard libraries, by specifying the compiler option, -nostdlib. Include -lgcc at the end of your compiler command line to resolve this reference. This links with the compiler support library libgcc.a. Putting it at the end of your command line ensures that you have a chance to link first with any of your own special libraries.

__main is the initialization routine for C++ constructors. Because GNU C is designed to interoperate with GNU C++, even C programs must have this call: otherwise C++ object files linked with a C main might fail. For more information on gcc, see Using GNU CC in GNUPro Compiler Tools. 0