- MinGW installation
- TDM-GCC
- Installation
- Code::Blocks Configuration
- Summary
- Alternative MinGW Compiler Toolchains
- Development Tools
- UnxUtils
- GnuWin32
- ZIP
- How to Install Code Blocks on Ubuntu 22.04, Ubuntu 20.04
- Code Blocks Features
- How to Install Code Blocks IDE on Ubuntu 22.04/20.04
- Choosing a C Compiler
- 20 Responses to “How to Install Code Blocks on Ubuntu 22.04, Ubuntu 20.04”
- Binary releases
- Microsoft Windows
- Linux 32 and 64-bit
- Mac OS X
- See also
- Build system
- Debugging
MinGW installation
A compiler toolchain is what Code::Blocks uses to turn the code you type into it into numbers that the computer understands. As a compiler toolchain is a very complex undertaking it is not part of Code::Blocks itself but rather is a separate project that Code::Blocks then uses. The kind of compiler toolchains talked about on this page are «MinGW» toolchains. Which means «Minimalist GNU for Windows.» And «GNU» expands to «GNU’s Not Unix.» More information about the GNU project can be found on the GNU Home Page.
For most MinGW-based compiler toolchains, having your toolchain in your PATH is important because it means that during development the toolchain libraries will be accessible by default to your programs as you develop them and also makes it easier to use utilities such as CMake as they will be able to find your compiler toolchain. When you actually distribute your programs to other computers then you will copy the needed .dll files out of your toolchain directory and include them as part of your installer. On your machine they are in your PATH so you always have them, on your users computers they won’t have the compiler toolchain so there you provide the .dll files with your program.
TDM-GCC
TDM-GCC is the toolchain that will be used as the example for this guide. TDM-GCC statically links the required toolchain libraries into your final executable. Which means that when you create your installer for your final program there are less files to include — they are built into your executable itself. The Code::Blocks team recommends TDM-GCC.
Installation
Download the on-demand installer and run it.
Go through the installation pages, the red arrows are all the default options which we will be keeping and the last blue arrow is to indicate that you will be putting TDM-GCC into your system’s PATH.
Once you are ready, click Install to proceed.
Code::Blocks Configuration
Go to your Compiler settings:
And then under the «Toolchain executables» tab (red arrow), click on the ellipsis («. «, blue arrow) and choose the root directory where you installed TDM-GCC 32-bit. Once you have that directory chosen, in the «Program Files» sub-tab (green arrow) area fill out the fields as shown. If you aren’t using the TDM-GCC toolchain there might be minor variation in the executable names. If you choose the blue arrow ellipsis first then for each ellipsis you click on under «Program Files» you will already be in your TDM-GCC bin directory where the actual programs are.
Now, go to your Debugger settings:
Choose your default debugger (red arrow), and then fill in the Executable path for it as shown for TDM-GCC 32-bit (blue arrow).
Summary
You now have a Code::Blocks environment that is configured to use TDM-GCC 32-bit properly. Using this guide as a template you can easily set up alternative compiler toolchains no matter the source — just follow the same basic procedure.
Alternative MinGW Compiler Toolchains
MinGW-Builds ➡ In, «Toolchains targeting Win32 or Win64,» ➡ «Personal Builds,» ➡ «mingw-builds,» ➡ Version, ➡ Threading Model, ➡ Exception Model, ➡ Revision.
Mingw-w64 — The parent project of MinGW-Builds, includes much more than is necessary — MinGW-Builds will usually suffice instead of the full works.
MinGW Equation — A package that also provides OpenMP.
Development Tools
Normally you should not need many of these tools. ZIP is convenient, especially when: building Code::Blocks itself, but other than that these tools only serve specialized purposes.
UnxUtils
GnuWin32
ZIP
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.04. Code 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.
Choosing a C Compiler
Upon the first launch of Code Blocks, you will be prompted with a Compiler auto-detection window:
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 the Clang compiler:
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.
You can also choose your default compiler by going to Settings > Compiler > Global Compiler Settings.
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.
20 Responses to “How to Install Code Blocks on Ubuntu 22.04, Ubuntu 20.04”
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’ .
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
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.
Binary releases
Please select a setup package depending on your platform:
NOTE: For older OS’es use older releases. There are releases for many OS version and platforms on the Sourceforge.net page.
NOTE: There are also more recent nightly builds available in the forums or (for Ubuntu users) in the Ubuntu PPA repository. Please note that we consider nightly builds to be stable, usually.
NOTE: We have a Changelog for 20.03, that gives you an overview over the enhancements and fixes we have put in the new release.
NOTE: The default builds are 64 bit (starting with release 20.03). We also provide 32bit builds for convenience.
Microsoft Windows
File | Download from |
---|---|
codeblocks-20.03-setup.exe | FossHUB or Sourceforge.net |
codeblocks-20.03-setup-nonadmin.exe | FossHUB or Sourceforge.net |
codeblocks-20.03-nosetup.zip | FossHUB or Sourceforge.net |
codeblocks-20.03mingw-setup.exe | FossHUB or Sourceforge.net |
codeblocks-20.03mingw-nosetup.zip | FossHUB or Sourceforge.net |
codeblocks-20.03-32bit-setup.exe | FossHUB or Sourceforge.net |
codeblocks-20.03-32bit-setup-nonadmin.exe | FossHUB or Sourceforge.net |
codeblocks-20.03-32bit-nosetup.zip | FossHUB or Sourceforge.net |
codeblocks-20.03mingw-32bit-setup.exe | FossHUB or Sourceforge.net |
codeblocks-20.03mingw-32bit-nosetup.zip | FossHUB or Sourceforge.net |
NOTE: The codeblocks-20.03-setup.exe file includes Code::Blocks with all plugins. The codeblocks-20.03-setup-nonadmin.exe file is provided for convenience to users that do not have administrator rights on their machine(s).
NOTE: The codeblocks-20.03mingw-setup.exe file includes additionally the GCC/G++/GFortran compiler and GDB debugger from MinGW-W64 project (version 8.1.0, 32/64 bit, SEH).
NOTE: The codeblocks-20.03(mingw)-nosetup.zip files are provided for convenience to users that are allergic against installers. However, it will not allow to select plugins / features to install (it includes everything) and not create any menu shortcuts. For the “installation” you are on your own.
If unsure, please use codeblocks-20.03mingw-setup.exe!
Linux 32 and 64-bit
Distro | File | Download from |
---|---|---|
codeblocks_20.03_amd64_oldstable.tar.xz | FossHUB or Sourceforge.net | |
codeblocks_20.03_i386_oldstable.tar.xz | FossHUB or Sourceforge.net | |
codeblocks_20.03_amd64_stable.tar.xz | FossHUB or Sourceforge.net | |
codeblocks_20.03_i386_stable.tar.xz | FossHUB or Sourceforge.net | |
codeblocks-20.03-1.el6.rmps.tar | FossHUB or Sourceforge.net | |
codeblocks-20.03-1.el7.rmps.tar | FossHUB or Sourceforge.net | |
For Ubuntu, use this PPA |
Note: The Linux packages above are compressed archives (tar, tar.xz or tar.bz2). When you decompress the package you downloaded on your system, you will find all the .rpm or .deb packages required to install Code::Blocks.
Note: On RedHat/CentOS older revisions of 6 (up to 6.2 as far as we know) you need to add repoforge (former rpmforge) to your repolist, to be able to install the needed wxGTK-package. See https://repoforge.org/use for an instruction.
Note: Redhat/CentOS probably also needs an installed hunspell-package, if you want to install the contrib-plugins.
Mac OS X
- Code::Blocks 20.03 for Mac is currently not available due to issues caused by Apple hardening their install packages and lack of Mac developers. We could use an extra Mac developer to work on these issues.
- The provided download contains an Application Bundle (for the i386 architecture) built for Mac OS X 10.6 (and later), bundling most Code::Blocks plugins.
See also
Build system
Code::Blocks implements a custom build system with very important features: ultra-fast dependencies generation, build queues and parallel builds are the most important ones to mention.
Debugging
The debugging subsystem has been greatly enhanced in the latest version. Automatic/manual watches, code/data breakpoints, call stack, disassembly listing and memory dumps are only few of its features.