The Compiler

After you have written your code with an editor, the compiler takes the source code files, for example C files (ending in .c) or C++ files (ending in .cpp or .cc) and transforms them into object files (ending in .o).

With the GNU compiler suite there are separate compilers for each language (that is, there is a different program that compiles C programs and one that compiles C++ programs). But actually, you don't use these programs directly, you use a program called a front end. The idea of a front end is that it can take options and arguments that are easy to remember and understand and figure out which programs to use and what options to use for each program.

For the GNU suite the main front end is called gcc. To get it to compile a program you type a command like this (in a DOS window or other command-line environment):

gcc -c -o foo.o foo.c

That command takes a source code file called foo.c, which, presumably, you wrote, and compiles it (that's what the -c means: compile) into an object file called foo.o (the -o option, followed by a file name, tells gcc to put the output of the compiler in a file with the name you give after the -o).

One of the things gcc does for you is figure out which compiler to use. It calls the C compiler if you give it a source file ending in .c, and calls the C++ compiler for files ending in .cc or .cpp. It also calls the preprocessor (called cpp, but not to be confused with the ending for C++ source files). Finally, gcc acts as the front end for the linker as well.

Take a look at the actual documentation for gcc online (from Cygnus Solutions).