How to Install Code::Blocks on Ubuntu 22.04

Code::Blocks is an open-source IDE (Integrated Development Environment) that is designed for the C/C++ and Fortran programming languages. It allows its users to write the programming scripts of the specified programming languages and run them. The users also debug their programming scripts on it. 

Code::Blocks can be installed on Linux, MacOS, and Windows-based systems. In this post, we will walk through the installation method of Code::Blocks on Ubuntu Jammy Jellyfish. 

What are the Installation Methods of Code::Blocks on Ubuntu 22.04?

Code::Blocks can be installed on Ubuntu by using any of the below-mentioned methods:

  1. Using the default repository
  2. Using the Debian package
  3. Using the flathub package

Method 1: Install Code::Blocks on Ubuntu Using the Default Repository

The first installation method of Code::Blocks on Ubuntu is by using the default package. The default package of Code::Blocks can be installed by following the mentioned steps. 

Step 1: Update the Packages

First, run the update command to ensure all the Debian’s package are up to date:

$ sudo apt update

Step 2: Find the Version of Code::Blocks

Now find the available version of Code::Blocks on Ubuntu:

$ sudo apt show codeblocks

Step 3: Install Code::Blocks on Ubuntu

Install the available version of the Code::Blocks with the apt command:

$ sudo apt install codeblocks -y

Step 4: Verify the Installation

To verify the installation, display the installed version of the “Code::Blocks” with the command:

$ codeblocks --version

Uninstall the Code::Blocks on Ubuntu 

To uninstall the Code::Blocks on Ubuntu using the apt command, run the command:

$ sudo apt purge codeblocks -y

Method 2: Install Code::Blocks on Ubuntu Using the Debian Package

Another installation method of Code::Blocks on Ubuntu is by using its Debian package. First download the Debian package of the Code::Blocks with the command:

$ wget http://security.ubuntu.com/ubuntu/pool/universe/c/codeblocks/codeblocks_20.03-3.1_amd64.deb

When the file is downloaded, then install it using the dpkg command:

$ sudo dpkg -i codeblocks_20.03-3.1_amd64.deb

The Debian package of the Code::Blocks has been installed. 

Remove the Code::Blocks on Ubuntu

To remove the installed Code::Blocks use the dpkg command:

$ sudo dpkg -r codeblocks

Method 3: Install Code::Blocks on Ubuntu Using the Flathub Package

The flathub contains a hundred Linux packages that can be installed using the flatpak command utility. To install the Code::Blocks on Ubuntu from the flathub, use the command:

$ flatpak install flathub org.codeblocks.codeblocks

To run the install package, use the command:

$ flatpak run org.codeblocks.codeblocks

Uninstall Code::Blocks 

To uninstall the Code::Blocks on Ubuntu with the flatpak command:

$ flatpak uninstall flathub org.codeblocks.codeblocks

These are the three different methods by which the “Code::Block” is installed on Ubuntu.

How to Use the Code::Blocks on Ubuntu?

To use the Code::Blocks on Ubuntu, first create a project and write the programming script. Debug the programming script and then run it to display the output. For example, a simple project to display the welcome message has been demonstrated. 

Step 1: Launch the Application

First, launch the application of the “Code::Blocks”:

$ codeblocks

Step 2: Create a Project

Now click on the “File“, then “New” and finally “Project” to create a new project:

Then choose the “Console application” and then click on the “Go” button:

Name the project and specify its location, then proceed to the next menu by clicking on the “Next” button:

Choose the compiler and click on the “Finish” button:

Step 3: Write the Script

Now write the programming script, we are writing a script to print a welcome message on the screen:

#include <iostream>

int main() {
    std::cout << "Welcome to ItsLinuxFoss" << std::endl;
    return 0;
}

Step 4: Build and Compile the Code

After writing the code, click on the “Build” menu  and then choose the “Build and Run”:

If there is no error, the output of the program will be displayed:

This is the way to use the Code::Blocks on Ubuntu. 

Conclusion

To install the Code::Blocks on Ubuntu, run the command “sudo apt install codeblocks -y”. Also, it can be installed using the Flathub and Debian packages. All the mentioned installation methods for the “Code::Blocks” on Ubuntu have been explained with the step-by-step guide. The usage of the Code::Blocks has also been demonstrated by running a simple script of C++ programming language.