The previous chapter installed gcc. This chapter adds three more
tools — make, gdb, and valgrind — plus the sanitisers, which
ship as flags inside gcc itself. All four are part of standard
Linux package repositories.
If you are on WSL 2, run these inside your Linux distribution.
If you are on native Linux, run them in your terminal as usual.
If you are on macOS, you need a Linux VM for this chapter — the
tools below are GNU/Linux-specific, and valgrind in particular
does not run on Apple Silicon.
Install the tools
On Debian, Ubuntu, and derivatives, or WSL 2:
sudo apt update
sudo apt install build-essential gdb valgrindbuild-essential is the meta-package — it pulls in make, gcc,
and the C standard library headers if any of them are missing.
Verify
Each of these should print a version banner without error:
gcc --version
make --version
gdb --version
valgrind --versionThe sanitisers do not need a separate install — they live inside
gcc. The fastest check is to compile a tiny program with the
address sanitiser enabled:
echo 'int main(void){return 0;}' > /tmp/check.c
gcc -fsanitize=address /tmp/check.c -o /tmp/check
/tmp/check
echo $?
rm /tmp/check.c /tmp/checkThe program does nothing, links against the AddressSanitizer
runtime, and exits with status 0. If the compile or run fails,
your distribution's gcc is older than the sanitisers — install
gcc-9 or later.
A working directory
Create a directory for this chapter's work and change into it:
mkdir ~/f05-practice
cd ~/f05-practiceYou will spend the rest of the chapter inside this directory.