Ubuntu Linux for Robotics · Lesson 23 of 96
Installing build tools: build-essential, cmake and colcon
The compiler, make, CMake and the colcon build tool, and checking their versions.
Estimated time · 30–45 min
Learning goals
What you will understand
- Explain installing build tools: build-essential, cmake and colcon in your own words
- Use it in a small workstation example
- Verify the result instead of assuming it worked
Understand the idea first
The mental model
Robotics code is compiled from source. The build-essential package installs the compiler (gcc, g++), make and the C library headers; cmake generates build files from CMakeLists.txt; colcon is the ROS 2 tool that builds a whole workspace of packages in dependency order.
Install them from apt where possible so they match your Ubuntu release, and check versions after installing. ros-dev-tools (from the ROS repository) installs colcon, rosdep, vcstool and related tools together.
Guided lesson
Work through these steps
- 1.
Open a terminal and record the current state before changing anything.
- 2.
Read the installing build tools: build-essential, cmake and colcon commands and predict what each one does.
- 3.
Run the commands one at a time and compare each output with your prediction.
- 4.
Write the commands that worked in a setup note you can repeat later.
Worked example
Read it before you run it
sudo apt update
# Refresh the package lists.
sudo apt install build-essential cmake git
# Install the compiler, make, CMake and Git.
gcc --version && g++ --version
# Confirm both compilers are installed.
cmake --version
# Confirm the CMake version (ROS 2 needs 3.16 or newer).
sudo apt install python3-colcon-common-extensions
# Install colcon and its standard extensions.
colcon --help | head -3
# Confirm colcon runs.What the example is doing
- 1.Lines without sudo only inspect or change files you own; sudo authorizes a system-wide change.
- 2.Read command output before moving to the next line. Stop if names, versions, disks, or paths differ from the lesson.
- 3.Comments beginning with # explain safety checks and are not executed by the shell.
Watch it run · Build and run
See what this code does
The terminal types this lesson's practice solution and runs it. The scene shows the kind of robot behaviour that code drives. It plays by itself and loops.
Demo for Installing build tools: build-essential, cmake and colcon. Expected result: g++
Practice code
Now type it yourself
Open a terminal, run the starter line by line (or save it as practice.sh and run bash practice.sh), and replace every TODO with your own command.
# TODO: print only the first word of the first line of g++ --version (use head -1 and cut -d' ' -f1)Expected output
g++Stuck? Show the full solution (try it yourself first)
g++ --version | head -1 | cut -d' ' -f1Expected result
How you know it worked
- Each command completes without an unexplained error.
- Your notes contain the command, the important output, and what it proves.
Practical exercise
Apply the lesson
Install the tools on a clean Ubuntu, record every version, compile a hello-world C++ file by hand with g++, then build the same file with a two-line CMakeLists.txt.
Before you continue
- You recorded the starting state
- Every command and output is understood
- The change can be repeated from your notes
If something goes wrong
Check ownership and permissions first. Do not add sudo unless the command changes a documented system location.
Check spelling, Ubuntu version, enabled repositories, and whether the previous installation command succeeded.