Skip to content
Permalink
e572cca6b4
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
20 lines (11 sloc) 1.18 KB

Demonstrate that we can compile programs by hand.

Being able to compile code manually is important as it demonstrates that you understand what the process is, the steps that go into creating an executable and how the various files interact.

Without this knowledge you will find it difficult to solve compiler issues in the future when you are using IDEs or build systems instead of manually compiling as you will not know what is supposed to be happening and so will not be able to identify which part has gone wrong.

Compiling by hand

Compile the **main.cpp** file into an executable called **byhand** using the 3 separate compile commands needed. Details are in the lecture slides.
  1. We need to compile the main.cpp file
  2. Because our program uses the code in the print_two .h and .cpp files we also need to compile print_two.cpp.
    • print_two.h is automatically included thanks to the #include lines in our code.
  3. Finally we need to link together those two object files to produce the final executable file that we are going to call byhand.

This executable should be placed in the bin/ directory.

{Check It!|assessment}(test-2677297096)