C++ Program-Development Cycle

The C++ program-development process consists of creating/modifying source code, compiling, linking and executing programs.

You have to create your program and compile it before it can be executed. This process is repetitive, as shown in Figure 1.11. If your program has compile errors, you have to modify it to fix them and then recompile it. If your program has runtime errors or does not produce the correct result, you have to modify it, recompile it, and execute it again.

The C++ compiler command performs three tasks in sequence: preprocessing, compiling, and linking. Precisely, a C++ compiler contains three separate programs: preprocessor, com­piler, and linker. For simplicity, we refer to all three programs together as a C++ compiler.

  • A preprocessor is a program that processes a source file before it is passed down to the compiler. The preprocessor processes the directives. The directives start with the # sign. For example, #include in line 1 of Listing 1.1 is a directive to tell the compiler to include a library. The preprocessor produces an intermediate file.
  • The compiler then translates the intermediate file into a machine-code file. The machine-code file is also known as an object file. To avoid confusion with C++ objects, we will not use this terminology in the text.
  • The linker links the machine-code file with supporting library files to form an executable file. On Windows, the machine-code file is stored on disk with an .obj extension, and the executable files are stored with an .exe extension. On UNIX, the machinecode file has an .o extension and the executable files do not have file extensions.

Figure 1.11 The C++ program-development process consists of creating/modifying source code, compiling, linking and executing programs

You can develop a C++ program from a command window or from an IDE. An IDE is software that provides an integrated development environment (IDE) for rapidly developing C++ programs. Editing, compiling, building, debugging, and online help are integrated in one graphical user interface. Just enter source code or open an existing file in a window, then click a button, menu item, or function key to compile and run the program. Examples of popular IDEs are Microsoft Visual C++, Dev-C++, Eclipse, and NetBeans. All these IDEs can be downloaded free.

Supplement II.B introduces how to develop C++ programs using Visual C++. Supplement D introduces how to develop C++ programs using Dev-C++. Supplement II.E introduces how to develop C++ programs from NetBeans IDE. Supplement I.F introduces how to develop C++ programs from a Windows command window. Supplement I.G introduces how to develop C++ on UNIX.

Source: Liang Y. Daniel (2013), Introduction to programming with C++, Pearson; 3rd edition.

Leave a Reply

Your email address will not be published. Required fields are marked *