Advertisement

How To

Code::Blocks Tutorial: What it is and How to Use it

Leri Koen

Leri Koen

  • Updated:

UpdatedMore in-depth description of the tool and additional tips

Code::Blocks is an open-source IDE (Integrated Development Environment). It helps you to work on software and programs you are developing, including coding, debugging, testing, and much more. It supports many compilers, such as GNU GCC (MinGW and Cygwin) and MS Visual C++. It is also free to download.

If this is your first time with this development tool, you’re in the right place! We’ll reveal what is Code::Blocks and how to use it.

Code::Blocks Tutorial: What it is and How to Use it

What is Code::Blocks?

Simply put, Code::Blocks is a free cross-platform integrated development environment for C/C++ and Fortran. Code::Blocks is built around a plugin framework, which means you can extend its core functionality with various plugins. Essentially, Code::Blocks is perfect for building onto because with easy integration with user-made plugins; you don’t need to edit any of the source code to add the functionality you need.

Although the software is open-source, so if you need to edit the code, you can. While Code::Block inherently supports the functionality of multiple compilers and debuggers, it isn’t in itself any of these systems. 

You can think of Code::Blocks as a house. The house itself is an empty shell, but it has rooms that certain functions and systems can use. Not all Code::Blocks installation files contain compilers. Instead, Code::Blocks can use the functionality of whatever compilers you have installed, whether that’s GCC, Clang or Visual C++, or any other compiler that tickles your fancy. While you let the house metaphor simmer, let’s take a look at some of the features Code::Blocks is known for.

Code Blocks tutorial what it is and how to use it

Code Editor

This integrated development environment (IDE) features code folding and syntax highlighting, driven by a Scintilla editing component. It also features a class browser, hex editor, C++ code completion, among various other utilities. The code editor organizes any files you have open into easily accessible tabs and supports personalized syntax highlighting colors, font, and font size selection. 

Compilers

Code::Blocks features support for multiple compilers. Among the most widely used supported compilers are GCC, Digital Mars, LLVM Clang, MinGW, Microsoft Visual C++, Watcom, LCC, Borland C++, and the Intel C++ compiler. Code::Blocks was written in C++ but features decent support for other coding languages such as Fortran and D. The installation file also includes a plugin with support for further programming languages. 

Debugger

The Debugger shipped with the Code::Blocks installation file has full breakpoint support. A Breakpoint refers to an intentional pause or stopping point written into a program. Breakpoints are put in place for debugging purposes to gather more information about a program during its execution and are sometimes simply called pauses.

Code::Blocks streamlines the debugging process by giving you access to the argument display, call stack, thread switching, custom memory dump, CPU registers, local function symbol, disassembly, and GNU Debugger Interface. 

Easy User Migration

Code::Blocks is an increasingly popular integrated development environment. It, therefore, has features specifically designed for users migrating from other IDE’s. Including Dev-C++, Microsoft Visual C++ project import for MSVC 7 and 10, and Dev-C++ Devpak support.

Code::Blocks Tutorial: How to Use it

With any software, before you learn to use it, you need to install it. While most installs are as simple as clicking a download button, accepting a bunch of conditions, and voila, Code::Blocks might require a little thought. 

To condense a long process, if you have a compiler already set up on your system, you simply click the download button, and you’re home free. This version doesn’t come with a built-in compiler, so you’ll just choose the compiler you have installed when it asks you to during use. 

If you don’t have a compiler pre-installed, you’ll need a different installation file. To access this, click the link underneath the Code::Blocks download button, and you’ll get to the official website. Now click ‘Download the binary release,’ which is the easiest way to get the utility installed, now onto the bit that requires thought or at least some reading. You’ll see a list of download links if you scroll down to ‘Microsoft Windows.’ The one you want that includes a compiler is called ‘codeblocks-20.03mingw-setup.exe’. Here you can choose to either download from FossHUB or Sourceforge.net.

The minds behind Code::Blocks think of everything. On the list of downloads is an executable file (.exe) for people who don’t have administrative rights on their PCs, and another exe that includes all the Code::Blocks plugins. They really try to make things as easy as possible, not just within their IDE but also with installation. Here’s an easy guide for troubleshooting Code::Blocks if it misbehaves.

Installing Code::Blocks

To get started, follow these steps:

  1. Download the Code::Blocks installer as mentioned above.
  2. Run the installer. It’s a standard installer for Windows; just press Next after reading each screen. If using another operating system, choose the appropriate option on the downloads page referenced above.
  3. If you’re planning on installing a compiler after you’ve installed Code::Blocks, read the information provided in the installer. Also, see this link for help setting up your compiler.
  4. If you downloaded the installer that doesn’t come with MinGW, you may have to configure the compiler manually (usually Code::Blocks auto-detects the compiler).

Starting your first project

Step 1. Launch the Project Wizard

Select File->New->Project… to start a new project. You can select from many types of templates to help get your project started. For your first project, select Console application, as this is the most common for general purposes. Click Go.

Step 2. Select the destination for your project.

Choose your programming language, (for example C++) when prompted for a language. Then, on the next screen, give the project a title and select a destination folder. Code::Blocks will generate the remaining entries from these two.

Step 3. Choose your compiler.

This is often the default compiler that you use on your machine. The default builds will be debug & release. If another option is needed, select it here.

Step 4. Finish

After selecting Finish, you’re on your way to your first project!

How to Use Code::Blocks for C++

Once you’ve installed Code::Blocks on your PC, all that’s left to do is run it. As soon as you start Code::Blocks up, you’ll see a list of compilers. The utility will detect which one you have and automatically select it. It will ask you if you want to make the compiler the default viewer for C++ files, which you should.

Next, click on File> New >Project, and you’ll see a new window. Select ‘Console application’ and click ‘go.’ You’ll need to click ‘Next’ in succession until the language selection dialog box opens. Choose the programming language you use, and then you’ll be prompted to choose a place to save your project. 

Rather place the project in its own folder because it is likely to create several files. Give your project a name and click ‘Next.’ Now, you will set up your compiler. You don’t need to change any settings you see here, so just click ‘finish’ and open the main.cpp file on the left of the screen. 

By now, you should have your main.cpp file, which you can modify if you wish. Currently, it just says ‘Hello World!’, run it as is. Hit F9, which compiles and then runs the program. You now have a working sample program. The main.cpp code can simply be edited and then compiled and run again using F9.

How to Use Code::Blocks in Google Docs

Code::Blocks is available as a plugin for Google Docs. Simply go to the Google Workspace Marketplace, type in Code::Blocks and click install. Read through and accept all the permissions if they’re agreeable. Otherwise, you won’t be able to use its full functionality. 

Once you’ve completed the install, Code::Blocks is easy to use. Your first step is to create a new document in Google Docs. Next, head to ‘Add-ons’ and choose Code::Blocks from the drop-down menu. Code::Blocks will open up a new panel on the right side; from here, you’ll have access to all the utility’s functionalities. 

Next, you need to write or paste code into the body of the document. Once you have your code in place, select it, and you’ll be able to choose a language from the language drop-down menu or a theme from the theme drop-down menu. Click preview to view your code, and as soon as your code looks exactly how you want it, click Format. Your code should now be formatted perfectly, and you can move on to the next piece of code.

Code to your heart’s content

Now that you know how Code::Blocks works, you can get started on your first project. It may seem complicated, but you should get the hang of it soon. Feel free to show us anything you’re currently working on!

Leri Koen

Leri Koen

Born and raised in South Africa I am the mother of two busy kids and one loving husband. Since leaving school I immediately started working and have been involved in many different industries where I learned a wide range of skills. Some of my skills range from marketing to management and even teaching special needs children, particularly those with severe developmental delays. I am a self-proclaimed holiday nut, taking any chance I can get to decorate and celebrate major holidays such as Easter, Halloween and Christmas, often planning these months in advance! I have a wide range of passions that I persue (as often as I can) such as reading, writing, bonsai, crafting, creating natural beauty products, listening to music and playing games (prefered platforms being PC and Xbox).

Latest from Leri Koen

Editorial Guidelines