Getting started
Ensure the make program is installed by checking make --version. If not installed, use package managers such as apt on Debian/Ubuntu or Homebrew on macOS.
Let's start with a simple C++ program consisting of three files: math.hpp, math.cpp, and main.cpp.
Manual compilation
g++ -c -I. -std=c++17 -Wall -Wpedantic -Werror main.cpp math.cpp
g++ -Wall -Wpedantic -Werror main.o math.o -o main
g++ -I. -Wall -Wpedantic -Werror main.cpp math.cpp -o main
This process involves creating object files and linking them to generate the executable. Now, let's simplify this with a Makefile.