How to Install Code Blocks on Ubuntu 22.04, Ubuntu 20.04

This tutorial will be showing you how to install Code Blocks on Ubuntu 22.04/20.04Code Blocks is a free, open-source integrated development environment (IDE) for C, C++ and Fortran. It can run on Linux, Mac, and Windows.

Code Blocks Features

  • Supports multiple compilers including GCC, Clang, Visual C++, MinGW, and many more
  • Custom build system and optional Make support.
  • Syntax highlighting and code folding
  • C++ code completion, class browser, a hex editor
  • A debugger with full breakpoint support
  • A plug-in system to support other programming languages.
  • And more

How to Install Code Blocks IDE on Ubuntu 22.04/20.04

Code Blocks is in the default Ubuntu package repository, so you can open up a terminal window and run the following command to install it.

sudo apt install codeblocks

Once installed, you can start Code Blocks IDE from Unity Dash or your preferred app launcher.

install code blocks ubuntu 16.04

Choosing a C Compiler

Upon the first launch of Code Blocks, you will be prompted with a Compiler auto-detection window:

c compiler

Two popular open-source C compilers available for Linux are:

  • GNU C Compiler – the defacto-standard open-source C compiler
  • Clang – Clang is much faster and uses far less memory than GCC and it provides extremely clear and concise diagnostics (error and warning messages).

To install gcc, run:

sudo apt install gcc

To install the Clang compiler:

sudo apt install clang

If you want to compile native Windows binaries on Linux, then you can install the mingw-w64 package.

sudo apt install mingw-w64

After choosing your default C compiler, you can start using Code Blocks to write programs.

ubuntu codeblocks setup

You can also choose your default compiler by going to Settings > Compiler > Global Compiler Settings.

codeblocks ubuntu

That’s it! I hope this tutorial helped you install Code Blocks on Ubuntu 22.04/20.04.

You may also want to learn how to identify bugs in your code.

Rate this tutorial
[Total: 81 Average: 4.6]

21 Responses to “How to Install Code Blocks on Ubuntu 22.04, Ubuntu 20.04

  • Jerry Black
    1 week ago

    After you add the PPA to apt-get and do an update. you need to call ‘sudo apt-get install codeblocks-common’ not ‘sudo apt install codeblocks codeblocks-contrib’ .

    • Xiao Guo-An (Admin)
      1 week ago

      If you do ‘sudo apt install codeblocks codeblocks-contrib’, the codeblocks-common package will be automatically selected.

  • why is the build and run ‘icons’ are hidden in toolbar? i am having the same problem even when installing from the ubuntu software store.

  • hello,
    I’m very new in Ubuntu. I have 16/04 version and I tried to do what you showed here.
    I got error. do you know how to help me? thank you

  • Oh damn, i tried to close the terminal image recursively and laughed out loud when i found my stupidity

  • it works well

  • Manas Halder
    5 years ago

    installed code block in ubuntu 18.04 but while i am reunning c code one error is coming in runtime
    ”sh:1: /home/mrmanas/program/demo: permission denied”
    “process returned 126(0x7E) ececution time: 0.003s”
    “press enter to continue”

  • Thanks for this! I downloaded the Codeblocks 17.12 deb files but had no idea how to install them all until I found your tutorial.

    CB 16 was getting so buggy and CB 17 seems to run much better.

  • this gives me the following error
    The following packages have unmet dependencies:
    codeblocks : Depends: libcodeblocks0 (= 17.12-1) but it is not installable
    Depends: libwxbase3.0-0v5 (>= 3.0.2+dfsg) but it is not installable
    Depends: libwxgtk3.0-0v5 (>= 3.0.2+dfsg) but it is not installable
    Depends: codeblocks-common (= 17.12-1) but it is not installable
    Depends: xterm but it is not installable
    Recommends: gcc but it is not going to be installed or
    g++ but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.

    • Antoine
      4 years ago

      Happening to me too on PopOS 19.10

    • batchali aashish
      4 years ago

      happened to me too. please suggest a solution .

    • did you get any solution?

      • ronaldo
        4 years ago

        What i did was copy and paste this whole command at terminal

        sudo apt install ./codeblocks_17.12-1_amd64.deb ./codeblocks-common_17.12-1_all.deb ./libcodeblocks0_17.12-1_amd64.deb ./codeblocks-dev_17.12-1_amd64.deb ./codeblocks-headers_17.12-1_all.deb ./*wx*.deb

        Since I’ve just dwl version 20.03, so I swaped “17.12-1” by “*”. Yet it displayed some dependencies errors, but sugested run

        sudo apt --fix-broken install 

        In the end I ran

         $ sudo apt update && sudo apt upgrade 

        and it updated another one. BTW I’m running Debian 10, lxde, lightdm

  • Gerald Langat
    4 years ago

    I’m very new in Ubuntu. I have 18.04 version and I tried to do what you showed here.
    and when I write a code in c++ on building and compiling it, a notification prompts that the file has not been built yet . I also installed the clang compiler using sudo apt install clang command. do you know how to help me? thank you

  • Works great on Kubuntu 19.10. Codeblocks 16.01 was getting rather old and the Codeblocks forums don’t do linux builds any more. So thank you for the tutorial. Much appreciated.

  • Thank you very much for your help 🙂

  • Thanks

  • romitbikram
    4 years ago


Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community ( for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here