#005 – How do we develop programs? Part 2

Here’s the flowchart from the previous nibble, we let off from Step 4.

Step 4 – Compile the program

The compiler performs two functions (get it functions):

  1. Verifies that your source code conforms to the rules of the C++ language. This is referred to as the syntax.
  2. Converts C++ code into machine language instructions. The generation is an an object file. Object files have the .o, .obj file extension. Each file in your program generate a unique object file.

Step 5 – Link object files

When we create C++ programs, we split it into numerous files. This heaps with readability and organization. We then reference other files using headers.

Thus, after compilation we have these separate files floating around.

This is the role of the linker.

A linker links combines all of the object files. An object file is created for each .cpp file.

Additionally, it links in library files and resolves cross-dependencies.

An example for an RPG game is shown below

The linker combines all of the separate object files

The linker combines all of the separate object files

NOTE: The process of converting the source files into an .exe is called building. The result of a build process is called a .. build. Tools such as make and CMake exist that perform this functionality.

Steps 6/7 – Testing & Debugging

Usually our programs don’t correctly work the first time. Thus, we perform an iterative loop of testing and debugging.

Testing is validating that our program does what it should.

Debugging is the process of identifying and fixing bugs.

Leave a Reply

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