<< 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 and SFML for Linux. For Macintosh computers, it is better to use Xcode rather than Code::Blocks. The installation of Xcode is described in How to Install SFML in OS-X.

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 Code:Blocks binary for your computer from: www.codeblocks.org/downloads/binaries.

    For Windows, download the codeblocks-XX.XXmingw-setup.exe, where X means any number. The mingw-setup version includes the gcc/g++ compiler preconfigured and makes our installation easier.

  2. Run Code::Blocks 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 the installation folder 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:Blcoks 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.

    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 click the "Create a new project" link.

    Opening screen

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

    Project type selection

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

    Empty project wizard starts

  4. 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

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

    Verify compiler

  6. In the project workspace, add a new empty file (File -> New -> Empty file).

    Project workspace

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

    Add file popup

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

    Save file dialog

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

    Confirm multiple selection dialog

  10. 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;
    }
    
  11. In the project workspace, build and run the project (Build -> Build and run).

    Project workspace

  12. 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