The standard C++ compilation process

suggest change

Executable C++ program code is usually produced by a compiler.

A compiler is a program that translates code from a programming language into another form which is (more) directly executable for a computer. Using a compiler to translate code is called compilation.

C++ inherits the form of its compilation process from its “parent” language, C. Below is a list showing the four major steps of compilation in C++:

  1. The C++ preprocessor copies the contents of any included header files into the source code file, generates macro code, and replaces symbolic constants defined using #define with their values.
  2. The expanded source code file produced by the C++ preprocessor is compiled into assembly language appropriate for the platform.
  3. The assembler code generated by the compiler is assembled into appropriate object code for the platform.
  4. The object code file generated by the assembler is linked together with the object code files for any library functions used to produce an executable file.

Many C++ compilers may also merge or un-merge certain parts of the compilation process for ease or for additional analysis. Many C++ programmers will use different tools, but all of the tools will generally follow this generalized process when they are involved in the production of a program.

The link below extends this discussion and provides a nice graphic to help: http://web.archive.org/web/20190419035048/http://faculty.cs.niu.edu/~mcmahon/CS241/Notes/compile.html

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents