Code::Blocks is a free and open-source software highly extensible Integrated Development Environment (IDE) for the C, C++, and Fortran programming languages. It features support for a wide range of compilers, parallel builds, and multi-target projects and also provides an interface with GNU GDB. The code editor in Code::Blocks features syntax highlighting, code folding, a tabbed interface, code completion, a class browser, and smart indenting. Code::Blocks is one of the most popular IDEs for C++ development and is used by many companies and organizations worldwide. The following tutorial will teach you how to install Code::Blocks on an Ubuntu desktop using the command line terminal.
The following tutorial will teach you how to install Code::Blocks on Ubuntu 22.04 Jammy Jellyfish or Ubuntu 22.04 Focal Fossa Linux with cli commands and the command line terminal with two different methods for Ubuntu users to select from.
Table of Contents
Recommended Steps Before Installation
Before proceeding with the tutorial, ensuring your system is up-to-date with all existing packages is good.
sudo apt update
Optionally, you can list the updates for users who require review or are curious.
sudo apt --list upgradable
Proceed to upgrade any outdated packages using the following command.
sudo apt upgrade
#1st Method: Install Code::Blocks – Ubuntu Repository
Install Code::Blocks
The first and easiest method to install Code::Blocks is to use the APT package manager, which can be done using the following command.
sudo apt install codeblocks -y
Install Plugins
Optionally, you can install the “codeblocks-contrib” package. This will allow you to install plugins and other features to enhance your IDE.
sudo apt install codeblocks-contrib -y
#2nd Method: Install Code::Blocks – Flatpak/Flathub
The second option is to use the Flatpak package manager, which is available from the default Ubuntu repository but not installed, given it’s a competitor to Snaps and the Snapcraft store.
First, install the Flatpak manager; this can be skipped if installed.
sudo apt install flatpak -y
For users installing Flatpak for the first time, it is often recommended to reboot your system. Failure to do this can occur in odd issues, such as wrong paths for icons.
sudo reboot
SKIP THE REBOOT IF FLATPAK IS INSTALLED.
Next, you need to enable Flatpack using the following command in your terminal.
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
Next, you can install the Code::Blocks Flatpak with the following command.
flatpak install flathub org.codeblocks.codeblocks -y
If the above command does not work and you receive the “error: Unable to load summary from remote flathub: Can’t fetch summary from disabled remote ‘flathub,” use the following command.
sudo flatpak remote-modify --enable flathub
Once installed, you can proceed to launch.
Launch Code::Blocks on Ubuntu Linux
Now, the best method to launch Code::Blocks is using the application icon.
Activities > Show Applications > Code::Blocks
Example:
Alternatively, you may want to use it for applications quite frequently. Right-click the icon and add it to favorites, making the icons appear on the taskbar.
The first time you open the IDE, you will notice a prompt asking you about the compiler choice. Set the default, which you can change later by installing additional compilers.
Example:
Once open, you will land at the default application start screen. For first-time users, I would strongly recommend visiting the Code::Blocks user manual.
Example:
How to Update or Upgrade Code::Blocks
Next are the commands to run in your terminal to check for updates. These commands will blanket-check all installed packages on your system that match the installation package manager. Ideally, you should run this regardless, even if auto-updates are set up to ensure your system is up-to-date, and no update errors occur for newer users.
Update APT Method
sudo apt update && sudo apt upgrade
Update Flatpak Method
flatpak update
Remove Code::Blocks on Ubuntu Linux
Remove APT Method
For users that installed the APT version, remove the application as follows.
sudo apt autoremove codeblocks
Remove Flatpak Method
To remove the Flatpack version, run the following command.
flatpak uninstall --delete-data org.codeblocks.codeblocks
Another handy hint can be to use the following command to ensure Flatpak has not left behind any unnecessary packages as it is known to sometimes.
flatpak remove --unused