Node:The compiler, Next:File names, Previous:Basic ideas, Up:Using a compiler
When you compile a program, the compiler usually operates in an orderly sequence of phases called passes. The sequence happens approximately like this:
GNU environments use a simple command to invoke the C compiler:
gcc
, which stands for "GNU Compiler Collection". (It used to
stand for "GNU C Compiler", but now GCC can compile many more
languages than just C.) Thus, to compile a small program, you will
usually type something like the following command:
gcc file_name
On GNU systems, this results in the creation of an executable
program with the default name a.out
. To tell the compiler
you would like the executable program to be called something else,
use the -o
option for setting the name of the object code:
gcc -o program_name file_name
For example, to create a program called myprog
from a file
called myprog.c
, write
gcc -o myprog myprog.c
To launch the resulting program myprog
from the same directory,
type
./myprog