The Compilation Process in C++ - dummies

By Stephen R. Davis

You need two programs to create your own C++ programs. First, you need a text editor that you can use to enter your C++ instructions. Any editor capable of generating straight ASCII text letters will work.

However, an editor that knows something about the syntax of C++ is preferable; it can save you a lot of typing, and sometimes highlight any mistakes you might make as you type, in much the same way that a spell checker highlights misspelled words in a word processor.

The second program you need is a compiler that converts your C++ source statements into machine language that the computer can understand and interpret. This process of converting from source-code C++ statements to machine code is called building. Graphically, the process looks something like this:


The process of building a program actually has two steps: The C++ compiler first converts your C++ source code statements into a machine executable format in a step known as compiling. It then combines the machine instructions from your program with instructions from a set of libraries that come standard with C++ in a second step known as linking to create a complete executable program.

Most C++ compilers these days come in a software package known as an Integrated Development Environment or IDE. IDEs include the editor, the compiler, and several other useful development programs together in a common bundle. Not only does this save you from having to purchase the programs separately, but also offers productivity benefits by combining them into a single package:

  • The editor can invoke the compiler quickly without making you switch back and forth manually.

  • The editors in most IDEs provide quick and efficient means for finding and fixing coding errors.

  • Some IDEs include visual programming tools that allow the programmer to draw common windows such as dialog boxes on the display.

  • The IDE generates the C++ code necessary to display onscreen boxes automatically.

    As nice as that sounds, the automatically generated code only displays the windows. A programmer still has to generate the real code that gets executed whenever the operator selects buttons within those windows.

Invariably, these visual IDEs are tightly coupled into one particular operating system. For example, the popular Visual Studio is strongly tied into the .NET environment in Windows. It’s not possible to use Visual Studio without learning the .NET environment — and something about Windows — along with C++ (or one of the other .NET languages). In addition, the resulting programs only run in a .NET environment.

Versions of Code::Blocks for these three operating systems (as well as a few others) are available for free. You can also download the Windows 13.12 binary.