How to set up a development environment for GCC on Ubuntu¶
GCC (GNU Compiler Collection) is a set of compilers that supports a number of programming languages, including C, C++, Assembler, and others. It is the
This guide shows how to install GCC and related tooling, including a build system and debuggers, on Ubuntu Desktop.
Installing GCC¶
The GCC toolchain, including past versions and cross-compilers for different architectures, is included in the Ubuntu package repository. The gcc
package always depends on the currently default version of GCC for your platform.
Install GCC compilers for C and C++:
sudo apt install gcc g++
Confirm the version of the installed compiler:
dev@ubuntu:~$
gcc --version
gcc (Ubuntu 14.2.0-4ubuntu2) 14.2.0
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Installing editing and debugging tools¶
A number of Integrated Developer Environments (IDEs) that are available from Ubuntu DEB and snap repositories provide support for developing C/C++ applications. Many developers also opt for using advanced text editors with language-specific extensions based on Language Server Protocol (LSP), such Vim or Visual Studio Code (or its
Text editors and Language Server Protocol (LSP)¶
Advanced text editors can be extended using LSP plugins to enhance the user experience with C/C++.
- Vim with Python LSP
A mode-driven text editor with powerful editing features. Combined with an LSP, such as ccls, it offers code completion, linting, navigation, and others.
Install with:
sudo apt install -y vim ccls
- Codium
The freely-licensed binary distribution of Microsoft’s Visual Studio Code. It includes extensive C/C++ support out of the box, and numerous extensions available from the open-source Open VSX registry provide support for additional functionality for coding with C. For example, the all-in-one C/C++ Extension Pack.
Install with:
sudo snap install codium --classic
- Visual Studio Code
The popular editor from Microsoft with an extensive range of extensions for C/C++ development, including the C/C++ extension also from Microsoft.
Install with:
sudo snap install code --classic
Integrated development environments¶
Some of the most common IDEs for Python are:
- Code::Blocks)
A dedicated C, C+, and Fortran IDE. For its ease of use, it’s often featured in C/C++ programming tutorials.
Install with:
sudo apt install -y codeblocks
- Eclipse CDT™ C/C++ Development Tools
An C/C++ IDE based on the Eclipse IDE platform.
Install with:
sudo snap install eclipse --classic
From within Eclipse, install CDT by going to
and usehttps://download.eclipse.org/tools/cdt/releases/latest/
for the Work with: field.Install with:
- Apache NetBeans
The NetBeans C/C++ Development Pack adds support for C/C++ to NetBeans.
Install with:
sudo apt install default-jre sudo snap install netbeans --classic
From within NetBeans, install the C/C++ Pack by going to
.
Debuggers, profilers, and other tooling¶
The standard debugger developed for GCC is GDB. Other tools, such as gprof (part of binutils
) and Valgrind provide support for profiling and advanced dynamic analysis.
Install with:
sudo apt install -y gdb valgrind
(The binutils
package is installed automatically with gcc
.)
Build systems¶
The standard for GNU software is GNU Make. For larger projects and a more modern experience, consider CMake.
Install with:
sudo apt install -y make cmake
What next¶
See the tutorial introducing the use of GCC and related tooling: Develop with GCC on Ubuntu.