You are on page 1of 27

2014

Tutorial on the
installation,
configuration and use of
Code::Blocks

Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

Contents
1

Introduction .................................................................................................................................... 1

Installation of Code::Blocks on a Microsoft Windows machine ..................................................... 2


2.1

Downloading Code::Blocks ..................................................................................................... 2

2.2

Installing Code::Blocks ............................................................................................................ 3

Installation of Code::Blocks on a Linux machine............................................................................. 7

First time compilation using Code::Blocks ...................................................................................... 8


4.1

Your first C project .................................................................................................................. 8

4.2

C99 standard ......................................................................................................................... 15

Student exercises .......................................................................................................................... 18

Code::Blocks errors and fixes ........................................................................................................ 24


6.1

Compiler executable not found ............................................................................................ 24

Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

1 Introduction
For the exercises in module 1 and module 2 of TU13: Embedded Systems we will be making use of
an IDE or Integrated Development Environment to do most of our programming. An IDE is a software
application that provides comprehensive facilities to computer programmers for software
development. It normally consists of a source code editor, compiler and a debugger. Most modern
IDEs also offer intelligent code completion features and all kinds of plugins which add extra features
to the environment.
In this case we will make use of Code::Blocks, a free C, C++ and Fortran IDE built to meet the most
demanding needs of its users. It is designed to be very extensible and fully configurable.
This tutorial will guide you through the installation of Code::Blocks and will also teach you how to
compile C projects and make use of some nifty features of Code::Blocks.

Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

2 Installation of Code::Blocks on a Microsoft Windows machine


The following steps are to be followed if you are working on a Windows PC. In case you are using a
Linux machine please skip to Section Error! Reference source not found..

2.1 Downloading Code::Blocks


Before starting with the actual installation of Code::Blocks you will need to download the installer.
Use your favorite browser to go to the website of Code::Blocks www.codeblocks.org.

Figure 1 The Code::Blocks website

Once there, locate the Downloads link in the left Main navigation menu as indicated in Figure 1.
Code::Blocks is not only free but also open source. In other words you can download the source code
of Code::Blocks and compile it yourself for the system you wish to use it on. However we will not be
doing that here.
For a Windows machine you need to select the Download the binary release link as indicated in
Figure 2.

Figure 2 The Downloads section of the Code::Blocks website


Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

Next scroll down the page until you reach the Windows 2000 / XP / Vista / 7 section. Now select
the Sourceforge.net mirror for the codeblocks-13.12mingw-setup.exe binary as indicated in Figure
3 (the version may differ a bit by the time you download this. Just make sure to pick the binary with
mingw). This installer already includes the necessary C and C++ compiler we need.

Figure 3 The different download options for a Windows machine

By clicking the URL of Sourceforge.net you will be brought to Sourceforge and your download will
commence in a few seconds.

2.2 Installing Code::Blocks


Make sure you are connected to the Internet while performing the following installation steps
because the Code::Blocks installer will download additional components and plugins during the
installation process.
Locate the binary installer on your system (usually found in your Downloads directory or wherever
you choose to save the installer).
The main installation screen is presented as shown in Figure 4.

Figure 4 The main installation screen of Code::Blocks

Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

Click next to continue the installation. The following screen will present you the license agreement
as shown in Figure 5. Click I Agree if you agree with the presented license agreement.

Figure 5 Code::Blocks license agreement

Next you need to select the required components that need to be installed. Make sure to select the
Full: All plugins, all tools, just everything type of installation as shown in Figure 6. Do take note
that you will need about 250MB of free space. Once you are ready click next.

Figure 6 Code::Blocks installation type and component selection

Last is the selection of the installation location as shown in Figure 7. In most cases this can be left
unchanged. However if you prefer to install Code::Blocks in a different location you are free to do so.

Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

Figure 7 Code::Blocks installation location

To start the actual installation process click the install button and wait for the installation (Figure 8)
to finish.

Figure 8 Code::Blocks installation process

Once the installation process is finished you will be presented with the question if you wish to run
Code::Blocks now (Figure 9). Pick either. You can always start Code::Blocks using the new entry in
your start menu or the icon on your desktop.

Figure 9 Running Code::Blocks after installation

The installer will present you with the second to last screen indicating that the installation process
finished successfully as shown in Figure 10. Click the next button.

Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

Figure 10 Code::Block installation finished successfully

Next click the finish button to close the installer (Figure 11).

Figure 11 Completion of the Code::Blocks installation

Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

3 Installation of Code::Blocks on a Linux machine


Precompiled packages are available for most Linux distributions (Debian, Suse, Fedora, ). It is also
possible to compile Code::Blocks from source.
For some distributions the main package repositories also host an older version of Code::Blocks
which can be easily installed. If you want a newer version it is also possible to use one of the publicly
available community repositories.
Since there are so many options for Linux, depending on the distribution you are using, the
installation of Code::Blocks on Linux is out of the scope of this tutorial.
Installation instructions can however be consulted on the Wiki page of Code::Blocks, which can be
found at http://wiki.codeblocks.org/.
In case of problems please contact the course tutor

Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

4 First time compilation using Code::Blocks


The first time you start Code::Blocks you will be presented with the default perspective shown in
Figure 12. A perspective is a sort of layout of all the visible toolbars and their different locations.

Figure 12 Default perspective of Code::Blocks on startup

If you receive an error concerning the GNU GCC Compiler that cannot be found, than please refer to
Section 6.1.

4.1 Your first C project


Lets start with the creation of a new C project. Select File => New => Project (as indicated in Figure
13).

Figure 13 Creating a new project

You are now presented with the new project wizard as shown in Figure 14 which will help you with
the creation of your C project. Under projects select the Console application and click the go
button. A console application is an application run via terminal. It has no graphical user interface
(GUI) with buttons but only a simple console prompt. This is most typical for embedded applications.

Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

Figure 14 Project wizard - application selection

The next window shows some basic information about the project type (Figure 15). Click next to
continue.

Figure 15 Project wizard - basic information

The subsequent screen (Figure 16) requests the programming language that is to be used. Make sure
to select C here and not C++ as we will be learning the C programming language. Click next to
continue.

Figure 16 Project wizard - language selection


Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

10

Next you need to provide a title for this project and indicate where the project files should be saved
on your system. You only need to fill in the two upper inputs (Project title and Folder to create
project in). The other values are automatically generated for you as shown in Figure 17). Click next
when you are ready.

Figure 17 Project wizard - project title and location

Last but not least you need to select your compiler. Select the GNU GCC Compiler as indicated in
Figure 18. Make sure a check is placed next to Create Debug configuration and not next to Create
release configuration. We wont be using the release configuration. Leave all other parameters with
their default values. Click finish when ready.

Figure 18 Project wizard - compiler selection

You are now presented with the default programmers perspective of Code::Blocks. Figure 19
identifies the basic toolbars and windows within the default perspective.

The project and workspace manager (situated on the left in Figure 19) allows you to
manage your current projects bundled inside a workspace. This will allow you to add and
remove files from your project and define the current active project. It also provides a
shortcut to changing the options of a project.
The TODO list (situated on the right in Figure 19) gives an overview of tasks that need your
attention. You can add TODO items to this repository directly from your code files by adding
a comment proceeded by TODO but we will see an example of this later in the tutorial.

Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

11

The main code window (situated in the middle in Figure 19) shows the current open code
file and will be used to edit this file. You can change the file displayed here using the project
manager by double clicking a source file (Sources/main.c for example).
The logging window displays all output from tools used for compilation, linking and
debugging (situated in the right bottom corner in Figure 19).

Figure 19 The default programmers perspective of Code::Blocks

Lets try to open the Sources/main.c file and see what is inside (shown in Figure 20). The program
code shown is the most popular program code to show beginning programmers the basic structure
of a C program. The exact workings of this program will be explained in the TU13: Embedded
Systems course.

Figure 20 Auto-generated main.c file for new console application

Lets jump right in and run this program. Before this can be done we have to compile and link the
source code (what this actually means we will see in the first chapter of module 1). Luckily this is not
hard with Code::Blocks. All you have to do is select Build and Run in the Build menu (see Figure
21) or press the F9 function key on your keyboard.

Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

12

Figure 21 Building and running a program in Code::Blocks

Do take note to always select Build and run and not just Run. Because if you modified your
source code and select the Run option, Code::Blocks will run your previous build and not the latest
version of your source (since that is not yet compiled).
After doing this your project will be compiled and ran which will result in the output shown in Figure
22. Looks like the program outputs a Hello world! message to the terminal.

Figure 22 Hello World output

The moment we hit a key the terminal window is closed and we are returned to the Code::Blocks
environment.
Now if we check the logging window and select the Build log tab we can see the commands that
were used to invoke the compiler (Figure 23).

Figure 23 Build log of a successful build

When we select the Build messages tab we can see the generated compiler messages (Figure 24).
Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

13

Figure 24 Build messages of a successful build

Lets do something crazy and put a syntax error in our program and check what happens when we
try to compile and run this program. Go back to your Sources/main.c source file and remove the
semicolon (;) at the end of the line with the Hello world!\n message as shown in Figure 25.

Figure 25 Hello world with a syntax error

Make sure to save your changes by going to File => Save all files or by hitting CTRL-S while your
cursor is inside your main.c file. Goto Build => Build and run or hit F9.
Bam we hit a wall. The compiler gives us an error and even tells us whats wrong with our code.
Check out the Build log inside the logging window (shown in Figure 26).

Figure 26 Build log of hello world with a syntax error

The compiler returns the following error:


main.c:7:5: error: expected ';' before 'return'
It tells us that it expected a semicolon before the return statement. It also tells us that the error can
be found around line number 7 (give or take). Always check the lines of code for errors starting from
the line number given by the compiler and working your way back. The compiler is not always able
to give the exact line of code which is the actual cause of the error.
Also notice that your code editor indicates the place where an error occurred by placing a red
rectangle on the line reported by the compiler as shown in Figure 27.

Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

14

Figure 27 Hello world with a syntax error

If the compiler returns multiple error messages you can always switch between them by using
double clicking the messages in the Build messages tab of the logging window (see Figure 28).

Figure 28 Build messages of hello world with a syntax error

Now lets fix the error by placing a semicolon at the end of the printf function call as shown in Figure
29. Dont forget to save the file. Next select Build => Build and run or hit F9 on your keyboard. The
program should be running just fine again.

Figure 29 Hello world - fixing the syntax error

Make sure to always check the Build messages tabs even if your program is running fine.
Sometimes the compiler will generate warning which may indicate that you forgot something.
Warnings however will not retain the compiler from compiling your code but it may indicate code
constructs which contain logical errors.
Lets for example add an extra parameter to the printf function call as shown in Figure 30. Dont
break your head on what this exactly does, we will see this later in module 2.

Figure 30 Hello world - introducing a compiler warning

If you save and build the project you will notice that the program runs without a hitch but the
compiler generated a warning as can be seen in Figure 31.
Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

15

Figure 31 Build messages of hello world with a compiler warning

Remove the extra parameter from the code, save the file and build the project anew. It should run
without errors or warnings.

4.2 C99 standard


The C programming language comes in many standards. First there was the first informal
specification by Dennis Ritchie and Brian Kernighan called K&R C (1978). Next ANSI (American
National Standards Institute) published the C89 standard (also called ANSI C) (1989), later also
approved by the International Organization for Standardization (ISO) as C90. In 1999 ISO extended
and revised the standard as C99. The current version of the standard (approved in 2011) is known as
C11.
The GNU GCC Compiler, which is used here to compile our C projects, defaults to the C89 standard.
This means that some code constructs (we will see some examples during the course), which were
only added to the C standard later, are not supported. To fix this we need to tell the compiler to use
the C99 or C11 standard.
We can test this by adding the code shown below to the main function before the printf function call
as depicted in Figure 32. Make sure to replicate the code exactly as shown. You can also copy/paste
it from this tutorial.
for (int i = 0; i < 10; i++) {
printf("%d ", i);
}

Figure 32 Adding a C99 construct to the tutorial project code

After saving the main.c source file and building it you will get a compiler error message stating:
main.c|6|error: 'for' loop initial declarations are only allowed in C99 mode
main.c|6|note: use option -std=c99 or -std=gnu99 to compile your code
Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

16

This can be fixed by telling the compiler to use the C99 standard instead of the default one. Right
click the tutorial project and select Build options as shown in Figure 33.

Figure 33 Requesting the build options of the tutorial project

Make sure the Debug configuration of the project is selected on the left and GNU GCC Compiler
is the selected compiler on the top. Next open the Compiler settings tab followed by the Other
options tab. You will see an empty textbox as shown in Figure 34.

Figure 34 Code::Blocks custom compiler options

Add -std=c99 inside the textbox (without the quotes) as shown in Figure 35. Click OK to close and
save the compiler options for the project.
Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

17

Figure 35 Setting GNU GCC Compiler options for C99 standard

You should now be able to build the project (build messages should show successful build as
depicted in Figure 36) and run it (producing the output shown in Figure 37).

Figure 36 Successful build of tutorial project using C99 standard

Figure 37 Successful run of tutorial project using C99 standard

Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

18

5 Student exercises
As a student you will be required so solve several exercises for this course. These exercises will be
provided to you as workspace in Code::Blocks. A workspace is a collection of projects bundled
together. This Code::Blocks workspace will be compressed in a single zip file.
Lets for example check out the exercises for Chapter 2 - Simple Data Types. After extracting the
zip file you get the directory structure shown in Figure 38.

Figure 38 Directory content of exercises of chapter 2

To open the workspace we first need to start Code::Blocks. Next go to File => Open as shown in
Figure 39.

Figure 39 Opening a workspace in Code::Blocks

A dialog will appear asking you to the select the file to open. Next browse to the directory where you
extracted your chapter exercises. Now select the Chapter2.workspace file and click open as
depicted in Figure 40. Make sure not to select the layout file as it will not open the workspace and
confuse Code::Blocks.
Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

19

Figure 40 Selecting the workspace file to open

You should now get the project exercises listed in your project manager on the left as shown in
Figure 41.

Figure 41 Workspace and project listing of chapter 2 exercises

As you can see each exercise has its own project. When you expand both Sources and Headers of the
first exercise you will see a number of files there (main.c, student.c, tests.c and student.h). Your
starting point will always be student.c. This file will contain the instructions for the exercise and
extra information for you.
Open the student.c file of the first exercise (shown in Figure 42). You will see a section where you
are required to fill in your name. Below that are the exercise instructions which will make clear to
you what is to be done for this exercise.
student.c will always contain areas which have the tags START OF STUDENT CODE and END OF
STUDENT CODE where you, as a student, have to add your C programming code. Sometimes it will
also be necessary to add code to the student.h header file.
The student code areas will always have a TODO comment (2 forward slashes followed by TODO).
These special comments are automatically recognized by Code::Blocks and added to your TODO list
shown on the right of your perspective. This simplifies the task for you to know where you need to
add your C code.
Do take note that you will never be required to change any of the main.c or tests.c files unless
instructed specifically to do so.
Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

20

Figure 42 Different code areas of student.c

Something you have to know about the exercises is that these are accompanied by test code written
by the course instructors. This means that once you have implemented your solution and run the
project your code will automatically be tested by the instructors code.
This will give you immediate feedback of what is correct and what is not. Of course your code will be
checked by an instructor upon delivery but this mechanism allows you and us to test your solution
easily and quickly.
Lets start by building and running the first solution. Start by activating the first project (this is a
required step so Code::Blocks knows which project you want to build) by right clicking on the first
exercise and picking Activate project (this may not be available if the project is already active) as
shown in Figure 43. The name of the project will appear in bold once activated.

Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

21

Figure 43 Activating a project in Code::Blocks

Next select the Build and run option from the Build menu. You will get some build errors as
shown in Figure 44 because no implementation is provided yet.

Figure 44 Build messages when trying to build the first exercise of chapter 2

So lets try to solve the first exercise of chapter 2 as an example.


The instructions tell us to create a variable called number of integral type. We also need to initialize
it with a value of 15. You can achieve this by declaring the variable number inside the student code
area as follows:
int number = 15;

The final solution is shown in Figure 45.

Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

22

Figure 45 Solution for exercise 1 of chapter 2

When you save, build and run the solution you should get the output shown in Figure 46. Here you
can see the results of the automatic tests that are run based on your implementation. Since this is a
small exercise it only required a single test. However bigger exercises will most likely be covered by
multiple tests.

Figure 46 Output of solved exercise 1 of chapter 2

The output of the tests can serve as a guideline to what is going wrong with your solution. Lets for
example introduce a small mistake and change the value of number from 15 to 16 as shown in
Figure 47.

Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

23

Figure 47 Introducing a small mistake into the first solution

When we save, build and run the solution again we see that the project is compiled without errors
but that the test fails as indicated in Figure 48. It even tells you what went wrong (it expected 15 but
it got 16 ).

Figure 48 Small mistake in first exercises causes tests to fail

So if you fix the mistake, save, build and run the application it should pass all tests again.
As a final note before delivering your exercises always make sure that all tests pass when running
the different projects.
Also remember that each exercise is supplied to you as a project. So before building and running a
project make sure to activate it first.

Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

24

6 Code::Blocks errors and fixes


6.1 Compiler executable not found
If you start Code::Blocks for the first time after (re)installing it may happen that a yellow window
appears in the right bottom of your screen with the message Cant find compiler executable in your
configured search paths for GNU GCC Compiler as shown in Figure 49.

Figure 49 Code::Blocks error - Cant find compiler executable in your configured search paths for GNU GCC Compiler

This error can be easily fixed by going to the menu Settings => Compiler and select Reset Defaults.
Click Yes twice. Code::Blocks should inform you that it auto-detected the GCC MinGW compiler as
shown in Figure 50. Click OK and restart Code::Blocks. The error should not occur again.

Figure 50 Auto-detected GNU GCC Compiler

Copyright notice : This material can be freely used within the E.O.L.E.S. TEMPUS PROJECT consortium. Explicit authorisation of the authors
is required for its use outside this consortium EOLES TEMPUS PROJECT. This project has been funded with support from the European
Commission. This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may
be made of the information contained therein.

You might also like