steps from source code to executable

  • preprocess by preprocessor, gcc -E(ouput to stdout, use -o to file), combine .h with .c/.cc into translation unit, .i
  • compile by compiler, gcc -S, compile files either into several assembler input files, or into one assembler input file, .s
  • assembly by assembler, as, gcc -c, each assembler input file produces an object file, .o
  • linkage by linker, ld, combines all object files(those newly compiled, and those specified as input) into an executable file

use gcc -v to view the details

Print (on standard error output) the commands executed to run the stages of compilation. Also print the version number of the compiler driver program and of the preprocessor and the compiler proper.

scope and linkage, is on translation unit, not on file.

  • An object can be defined exactly once in a prgram.
  • It may be declared many times, but the types must agree exactly.