<< Back

How to Install Code::Blocks on Windows

On This Page

  1. Introduction
  2. Installing Code::Blocks
  3. Creating a Project

A. Introduction

This document describes how to install Code::Blocks on a Windows computer for the course CS-11: Introduction to Programming Concepts and Methodology, C++. For Linux computers, Code::Blocks installation is described in How to Install Code::Blocks on Linux. For Macintosh computers, use the free version of Visual Studio.

Code::Blocks is an Integrated Development Environment (IDE) used by many C++ software engineers and developers. An IDE is like a text editor with added features. It runs on the major platforms including Linux, OS-X and Windows. Code::Blocks is free, open source and configurable for use with different compilers including GCC/G++ using MinGW.

B. Installing Code::Blocks

Follow these instructions carefully. Do NOT just continue without completely reading each step of the instructions carefully or you will probably not install the software correctly. If in doubt ask a classmate or the instructor to verify what you are doing. If you cannot create a project after installing, then you will need to reinstall following these instructions more carefully.

  1. Download the codeblocks-20.03mingw-setup.exe binary for your computer from www.codeblocks.org/downloads/binaries.

    The mingw-setup version includes the gcc/g++ compiler preconfigured and makes our installation easier.

  2. Run the setup file and press the Next > button after reading the dialog.

    Opening Code::Blocks dialog

  3. Read the license and press the I Agree button.

    Code::Blocks license dialog

  4. Choose the default components as shown and press the Next > button.

    For Windows, if you do not see minGW go back to step 1 and download the correct file.

    Choose components to install

  5. Choose an installation folder (C:\CodeBlocks) as shown below and press the Install button.

    Do NOT use the default location or you may have problems later in the installation of SFML or the creation of a project. Instead, install at C:\CodeBlocks to make working at the command line and with SFML easier.

    Choose installation folder

  6. Choose to run Code:Blocks now by pressing the Yes button.

    This step allows us to immediately configure the compiler. You can come back to this step if you decide to run Code::Blocks later.

    Run Code::Blocks now

  7. Select the GNU GCC Compiler as shown, press the Set as default button and then press the OK button.

    If you have previously installed Code::Blocks, you may not see this dialog. If you are changing the compiler, you will need to manually set the compiler path (Settings -> Compiler -> Toolchain executables -> Compiler's installation directory).

    Choose compiler

  8. Make a choice for the file association and press the OK button.

    Choosing to associate Code::Blocks with C++ files means that Code::Blocks will start automatically whenever a C++ file is selected, such as by double-clicking an icon on Windows. If unsure, select "No, leave everything as it is (but ask me again next time)".

    Choose file association

  9. Exit Code::Blocks (File -> Quit) and then press the Finish button to exit the installer.

    Choose compiler

  10. Test the installation by creating a project as shown in the next section.

C. Creating a Project

  1. Start Code::Blocks and make sure the Compiler Options are correct by clicking the Settings > Compiler menu at the top of the main screen. Then find and set the following flags:

    Then press OK.

  2. Next click the "Create a new project" link or use the menus: File > New > Project.

    Opening screen

  3. In the New from template dialog select the Empty project template.

    Project type selection

  4. In the "Empty project" start screen press the Next button.

    Empty project wizard starts

  5. Continuing through the Empty project wizard, enter a project title and folder path and then press the Next button.

    Enter project title and folder path

  6. Continuing through the Empty project wizard, verify the GNU GCC compiler is selected and then press the Finish button.

    Verify compiler

  7. Add a new empty file to the project using the menu: File -> New -> Empty file.

    Project workspace

  8. If you get the following dialog press the Yes button.

    Add file popup

  9. Save the file using an appropriate file name (hello.cpp) and press the Save button.

    Save file dialog

  10. Confirm the multiple selection and press the OK button.

    Confirm multiple selection dialog

  11. In the file tab (hello.cpp), copy and paste the following program code.
    #include <iostream>
    using namespace std;
    int main()
        cout << "Hello, World!\n";
        return 0;
  12. In the project workspace, build and run the project (Build -> Build and run).

    Project workspace

  13. Verify you get a console window like the following after running the program.

    You should see both Hello, World! and that the process returned 0. Any value other than 0 means there is a problem. If you have problems ask the instructor or a classmate for help. Make sure the console has focus and then press any key to close the console.

    Project console

<< Back