The compilation step

  gcc -c file.c creates an object file file.o
  gcc file.c -lm would create an executable a.out. If file.c uses math functions (e.g. inluded <math.h>) the compiler would tell the linker to use the math default library [lib]m.[a] with the parts in angel brackets being substituted automatically.
-c

do not link yet. The resulting object code file can be put into an archive (library) and later linked into a program.

-I<dir>

look for include files also in <dir> Allows you to install e.g. a cross-compilation environment for Lego Robots on your system and generate code for this platform by directing the C compiler to use different header files.

-l<lib>

link the library <lib> to the program. If you have unresolved external errors look for the library which contains the necessary functions. You can use the nm <libxxxx.a> to search the libraries for those functions.a

-L<dir>

look for libraries also in <dir>

-O

Optimize code (usually differnt subparameters). Optimization can introduce subtle bugs or require that all libraries have been compiled the same way. That's why this is optional.

-g

Create debugging code (needed e.g. for symbolic debugging)

-pg

Create profiling code which tells you how much processing time functions take. Required to optimize your code properly.

-S

Tell compiler to stop after producing assembler code. Let's you see how your code looks in assembler. Useful for debugging or device programming.