Manual Code Blocks Simplecpp
Manual Code Blocks Simplecpp
Manual Code Blocks Simplecpp
1 Introduction 1
1.1 Code::Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Simplecpp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2 Code::Block IDE 1
i
List of Figures
1 Code::Block IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2 Menu Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
3 Main Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
4 Debugger Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
5 Compiler Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
6 Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
7 Editor, Start/Home Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
8 Shortcut to Create New Project or Open Existing Project . . . . . . . . . . . . . . . . . . 4
9 Shortcut to History of Projects Opened Using Code::Blocks . . . . . . . . . . . . . . . . . 5
10 Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
11 Welcome to Code::Blocks Simplecpp Setup . . . . . . . . . . . . . . . . . . . . . . . . . . 6
12 Accepting License Agreement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
13 License Inforamtion of Code::Blocks EP . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
14 Location of Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
15 Start Menu Folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
16 Application Shortcut Desktop Icon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
17 Installation Step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
18 Progress of Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
19 Basic Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
20 Completing the Insallation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
21 Code::Block Simplecpp IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
22 New form template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
23 New console application wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
24 Selecting language for the project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
25 Providing title and folder for the project . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
26 Selecting compiler for the project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
27 Project node with no files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
28 Adding file to the project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
29 Selecting type of file to be added in the project . . . . . . . . . . . . . . . . . . . . . . . . 16
30 Select checkbox to skip this window next time . . . . . . . . . . . . . . . . . . . . . . . . . 16
31 Select the language of the file added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
32 Details of file to be added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
33 Selecting the location and file name to be added . . . . . . . . . . . . . . . . . . . . . . . 18
34 Finalize details of file to be added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
35 Project node with ‘+’ sign indicating it can be expanded . . . . . . . . . . . . . . . . . . . 19
36 Project node expanded . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
37 Writing code in editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
38 New form template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
39 New console application wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
40 Selecting language for the project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
41 WinBGIm project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
42 Providing title and folder for the project . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
43 Selecting compiler for the project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
44 Finalize details of file to be added (for line project) . . . . . . . . . . . . . . . . . . . . . . 23
45 Project node with ‘+’ sign indicating it can be expanded . . . . . . . . . . . . . . . . . . . 23
46 Writing program in editor (line project) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
47 New from template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
48 Simplecpp project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
49 Providing title and folder for the project . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
50 Selecting compiler for the project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
51 Empty project node in Management window . . . . . . . . . . . . . . . . . . . . . . . . . 26
52 Adding files to empty project node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
53 Selecting c/c++ source for project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
ii
54 Selecting language for the file to be added . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
55 Giving location and name of the file to be added . . . . . . . . . . . . . . . . . . . . . . . 28
56 Finalize details of file to be added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
57 Project node with ‘+’ sign indicating it can be expanded . . . . . . . . . . . . . . . . . . . 29
58 opening file in editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
59 coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
60 Output of hello world project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
61 Output of line project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
62 Output of 3poly project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
63 Selecting Open under file in Menu Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
64 Select file with .cbp extension to open an existing project . . . . . . . . . . . . . . . . . . 32
65 Code::Block in Ubuntu Software Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
66 Installing Code::Block using command line . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
67 Installing simplecpp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
68 location of simplecpp/s++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
69 Compiler and debugger settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
70 Copying the compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
71 Change Toolchain Executable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
72 Changes to be made in Toolchain Executables . . . . . . . . . . . . . . . . . . . . . . . . . 37
73 Simplecpp’s directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
74 Additional Paths settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
75 Starting a new project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
76 Selecting the language for project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
77 Title for Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
78 Selecting Compiler to Compile the Program . . . . . . . . . . . . . . . . . . . . . . . . . . 40
79 Selecting simplecpp for projects including simplecpp . . . . . . . . . . . . . . . . . . . . . 41
80 Project Node when Expanded . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
81 Project Node when Expanded for helloworld.c (with code shown in editor) . . . . . . . . . 42
82 Project node when expanded for line.c (with code shown in editor) . . . . . . . . . . . . . 42
83 Project node when expanded for 3poly.cpp (with code shown in editor) . . . . . . . . . . . 43
84 Output for helloworld.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
85 Project build options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
86 Linker settings (Add Libraries) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
87 Interface for adding libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
88 Files/libraries to be added for graphic projects . . . . . . . . . . . . . . . . . . . . . . . . 45
89 Relative or absolute path for files/libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
90 libraries selected . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
91 Libraries added to project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
92 Output for line.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
93 Output for 3poly.cpp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
94 Select file with .cbp extension to open an existing project . . . . . . . . . . . . . . . . . . 49
iii
1 Introduction
1.1 Code::Blocks
“Code::Blocks is a free C++ IDE built to meet the most demanding needs of its users.” [1]. Developed by
‘The Code::Blocks Team’, Code::Block is a free, open-source [2] and cross-platform IDE, which supports
various free compilers. It is built around plugin framework, which allows functionality of Code::Block to
be extended by installing appropriate plugins. Plugins required for compiling and debugging are already
provided by default. This manual is prepared after installing and testing Code::Block on Ubuntu 12.041
and Windows 7.2
1.2 Simplecpp
Simplecpp is a package used to write and execute turtle based non-graphic/graphic programs. Simplecpp
is a package developed by Prof. Abhiram Ranade at IIT Bombay and the book on ‘An Introduction
to Programming through C++’ by Prof. Abhiram Ranade uses simplecpp to explain basic program-
ming. For more information, please refer to the Chapter 1 of the book. Simplecpp is integrated with
Code::Blocks and the simplecpp programs are tested with Code::Blocks on Windows 7 and Ubuntu 12.04.
2 Code::Block IDE
Code::Block IDE is shown in figure 1 (Ubuntu 12.04). The main parts of Code::Block along with figures
are discussed below
1
1. Menu bar:
Menu bar is shown in figure 2. Menu bar can be toggled using F10. Few important link in menu
bar are described below (described from left to right):
(a) File: File menu link contains options to create a new project, open an already existing project,
save file, save project, save workspace and save everything. It also contains options for closing
a single file, closing a project or closing entire workspace. Other options in File are to print,
export and quit the Code::Block
(b) Edit: All the editing options required for editor are provided in Edit.
(c) View: This menu link contains link for various perspectives and toolbars along with manager,
logs, script console, status bar, full screen.
(d) Project: Options related to the project is provided in this link which includes configuring build
options along with options for adding files, removing files and autoversioning of project.
(e) Build: Options for building the project, compiling a single file, running the project, building
and running the project, rebuilding the project and cleaning the project is provided in build.
Options for Building, rebuilding and cleaning the entire workspace is also provided along with
options to select target (debug/release) and analysing error one by one.
(f) Debug: Various Debugging options are provided in this link.
(g) Plugins: Various plugins can be executed using this link. The link to manage the plugins is
also provided here.
(h) Settings: This contains link for various settings, setting related to Environment..., Editor...,
Compiler and debugger..., Global Variables... and Scripting.... Script to be executed during
Code::Block start-up can also be edited here.
(i) Help: It contains information about Code::Block version, tips which can be toggled to be
displayed at start-up and information about various plugins.
2
(k) Replace: To replace required text in the file in active editor by some alternate text.
5. Manager:
Manager is shown in figure 6. It is labelled as Management. This window provides the list of all
the open projects and files for easy access to any required file of any project.
Figure 6: Manager
6. Editor:
Editor is shown in figure 7. Here, all the coding work will take place. It is provided in tabbed
3
fashion to work with many files at once. When no project is open, the start page or home page is
displayed in editor. The links given in start page is divided into two parts and explained below
7. Figure 8 is short-cut on Starting page of IDE for creating a new project and opening an already
created project. It also contains link for Code::Block forum where many useful resources can be
found along with other useful discussions. The link points to url http://forums.codeblocks.org/.
The second and third link points to BerLiOS Developer Site aims at enriching the Open Source
community by providing a centralized place for Open Source Developers to control and manage
Open Source Software Development.
8. Figure 9 is short-cut to list of projects and files already opened in the IDE. It is link to few projects
and files from history of IDE.
4
Figure 9: Shortcut to History of Projects Opened Using Code::Blocks
9. Logs:
Log window is shown in figure 6. It is labelled as ‘Logs & others’. This window acts as log for
various actions performed in IDE. All logs related to various activities can be checked at appropriate
windows.
5
3 Working with Code::Blocks and Simplecpp on Windows
In this section we discuss writing and building of three projects. First project (hello world.c) is a simple
program which displays hello world on output. The second project (line.c) uses graphics.h header file
and displays a line. The third project (3poly.cpp) uses simplecpp package and draws three polygons on
output. The simplecpp package is integrated with Code::Blocks-EP IDE
1. A window as shown in Figure 11 will be displayed after double clicking on the .exe file. Click
‘Next’.
2. A new window will be displayed as shown in Figure 12giving information on the license agreement.
Select ‘I accept the agreement’. Click ‘Next’.
6
3. A new window will be displayed giving license information of Code::Blocks EP as shown in Figure
13. Click ‘Next’.
4. A new window will be displayed as shown in Figure 14. This will display the location in which
Code::Blocks Simplecpp will be installed. By default it is C:\Program Files (x86)\Codeblocks-
Simplecpp. If you want to change this default location, click browse and select the appropriate
location. Click ‘Next’.
7
5. A new window will be displayed as shown in Figure 15 will be displayed. Click ‘Next’.
6. A new window will be displayed as shown in Figure 16 will be displayed asking whether a shortcut
application desktop icon should be created or not. Select ‘Create desktop icon’. Click ‘Next’.
8
7. A new window will be displayed as shown in Figure 17 will be displayed. Click ‘Next’.
8. A new window will be displayed as shown in Figure 18 will be displayed. This window will show
the progress of the installation. Click ‘Next’.
9
9. A new window will be displayed as shown in Figure 19 will be displayed . Click ‘Next’.
10. A new window will be displayed as shown in Figure 20 will be displayed . Select ‘Launch
Codeblocks-Simplecpp. Click ‘Finish’.
10
11. CodeBlocks IDE opens as shown in figure 21. Alternatively CodeBlocks-EP can be launched by
double clicking the desktop icon created or clicking on it’s shortcut icon in Start Menu Bar.
11
3.2 Writing a new C/C++ Program
This section is divided into writing non-graphic program, writing graphic program using graphics.h
header file and writing graphic program using simplecpp package.
2. When Go button is clicked a new window opens as shown in figure 23. Select checkbox “Skip this
page next time” so that the page is not displayed again. Click ‘Next’
12
Figure 23: New console application wizard
3. Next window enables user to select the language to be used for project as shown in Figure 24.
Select C/C++. Here, ‘C’ is selected for helloworld project. Click ‘Next’.
13
4. Next windows enables user to provide title for the project and the folder where user wishes to
create the project in. This is Shown in figure 25. After filling in the details click on Next.
5. Next window is used to select the compiler as shown in figure 26. By default ‘GNU GCC Compiler’
is selected. Click on Finish.
14
6. The project node opens in manager window as shown in figure 27. The project node is empty and
we have to add files to the project.
7. To add files to the project select project node and click on Filein menu bar, then click on ‘File...’
in options in ’New’. The process is shown in figure 28.
15
8. New from template opens as shown in figure 29. For our example select ‘C/C++ source’ and click
on Go.
9. A new window is displayed as shown in figure 30. Select the checkbox ‘Skip this page next time’
so that it is not displayed again.
16
10. Select the preferred language as shown in figure 31. We have selected ‘C’ for our helloworld example.
11. Figure 32 shows the window that opens to add the file. click on ‘...’ beside ‘Filename with full
path’.
17
A window as shown in figure 33 opens. Select the folder of the project and enter file name to be
added. Click on ‘Save’.
When ‘Save’ button is clicked the window in figure 32 opens again with full path and name of the
file. Select Debug and Release. Shown in figure 34. Click on Finish.
18
12. Management window now shows project node which can be expanded. Click on project node and
double click on ‘hello.c’ to open the file in editor shown in figure 35 and figure 36
Figure 35: Project node with ‘+’ sign indicating it can be expanded
13. When the main.cpp file opens in editor, user can start coding. Code is shown in figure 37.
19
3.2.2 Graphic Project using graphics.h
1. Click on New file button. The ‘New form template’ window as shown in figure 22 opens. For
graphics projects, select ‘WinBGIm project’. Go button gets highlighted (top right corner). Click
on Go.
2. When Go button is clicked a new window opens as shown in Figure 39. Select checkbox “Skip this
page next time” so every time new project is created this window should not come. Click on Next.
If this step has been performed earlier, this window will not be displayed.
3. Next window enables user to select the language to be used for project as shown in figure 40. For
20
the example hello world used in this manual select ‘C’ and click on Next.
4. Next window asks the user to select type of project. The options are ‘Add Console’ and ‘Graphics
only’ as shown in figure 41. Select ‘Graphics only’ and click on Next.
21
5. Next windows enables user to provide title for the project and the folder where user wishes to
create the project. This is Shown in figure 42. After filling in the details click on Next.
6. Next window is used to select the compiler as shown in figure 43. By default ‘GNU GCC Compiler’
is selected. Click on Finish.
22
7. The project node opens in manager window. The project node is empty and we have to add files to
the project. To add files to the project select project node and click on File in menu bar, then click
on ‘File...’ in options in ’New’. New from template opens as shown in figure 29. For our example
select ‘C/C++ source’ and click on Go. A new window pops out which have a checkbox ‘Skip this
page next time’. Select the checkbox so this window should not open every time a new file is added
to the project. Select the preferred language. For our example select ‘C’. A new window opens
which allows user to add the files to the project. Click on ‘...’ beside ‘Filename with full path’.
This is shown in Figure 32. A window as shown in figure 33 opens. Select the folder of the project
and enter file name to be added. Click on ‘Save’ (see steps 6-11 of section 5.2.1.1). Select Debug
and Release. Shown in figure 44. Click on Finish.
8. Management window now shows project node which can be expanded (figure 45).
Figure 45: Project node with ‘+’ sign indicating it can be expanded
23
9. Click on project node and double click on ‘line.c’ to open the file in editor. When the line.c file
opens in editor, user can start coding. Code is shown in figure 46.
24
2. Next window asks the user to select type of project. The options are ‘Add Console’ and ‘Graphics
only’ as shown in figure 48. Select ‘Graphics only’ and click on Next.
3. Next windows enables user to provide title for the project and the folder where user wishes to
create the project. This is Shown in figure 49. After filling in the details click on Next.
25
4. Next window is used to select the compiler as shown in figure 43. By default ‘GNU GCC Compiler’
is selected. Click on Finish.
5. The project node opens in manager window. The project node is empty as shown in figure 51. We
have to add files to the project.
26
6. To add files to the project select project node and click on File in menu bar, then click on ‘File...’
in options in ’New’. Shown in figure 52.
7. New from template opens as shown in figure 53. For our example select ‘C/C++ source’ and click
on Go.
27
8. Select the preferred language. For our example select ‘C++’ (figure 54).
A new window opens which allows user to add the files to the project. Click on ‘...’ beside ‘Filename
with full path’. This is shown in Figure 32. A window as shown in figure 55 opens. Select the
folder of the project and enter file name to be added. Click on ‘Save’.
28
In next window select Debug and Release. Shown in figure 56. Click on Finish.
9. Management window now shows project node which can be expanded (figure 57).
Figure 57: Project node with ‘+’ sign indicating it can be expanded
29
10. Click on project node and double click on ‘3poly.cpp’ to open the file in editor. When the 3poly.cpp
file opens in editor (figure 58), user can start coding. Code is shown in figure 59.
30
3.3 Building the Project
The process to build the graphics and non-graphics project is same, just Click on ‘Build’ and then ‘Run’
(or directly on ‘Build and run’). The output for the program used is shown in figure 60 for hello world
project, figure 61 for line project and figure 62 for 3poly project.
31
3.4 Opening existing program/project
Click on Open button 63. Browse to desired directory and open the file with .cbp extension as shown in
figure 64.
Figure 64: Select file with .cbp extension to open an existing project
32
4 Working with Code::Blocks and Simplecpp on Ubuntu
In this section we discuss writing and building three projects. First project (hello world.c) is simple
program which displays hello world on output. The other project (line.c) uses graphics.h header file and
displays a line. graphics.h is not supported by gcc, which is the default C/C++ compiler on Ubuntu.
The third project (3poly.cpp) uses simplecpp package and draws three polygons on output. We have to
install some packages, include few libgraph libraries during building the project with graphic.h header
file.
1 $ sudo apt−g e t i n s t a l l c o d e b l o c k s
33
Figure 65 shows Code::Block along with it’s logo in Ubuntu Software Center, while figure 66 shows
installation of Code::Block using command line. In figure 66 four underlined lines are:
line 1: Command to install the Code::Block.
line 2: Packages installed along with Code::Block.
line 3: Packages suggested along with Code::Block installation. libwxgtk2.84 package as mentioned above
is already installed in your system. libwxgtk2.8-dev package is not required.
line 4: Final list of packages that will be installed in your system
When command line prompts for [Y/n] enter ‘y’ and press enter. When Code::Block is run for first time,
It asks for default compiler. Select the appropriate compiler to proceed further. We have used ‘GNU
GCC Compiler’.
After the above mentioned packages are installed, download the libgraph package (download link
given in footnote5 ) and untar it in home directory. For this untarring tool must be installed on system.
Open the command line and follow the instructions given in listing 4.
1 $ cd l i b g r a p h − 1 . 0 . 2
2 $ ./ configure
3 $ sudo make
4 $ sudo make i n s t a l l
5 $ sudo cp / u s r / l o c a l / l i b / l i b g r a p h . ∗ / u s r / l i b
34
Figure 67: Installing simplecpp
35
4.4 Integrating Simplecpp with Code::Blocks IDE
To create a project using simplecpp package, we need to make some changes in the compiler and debugger
settings. The steps to make the required changes are as given below.
1. Open Code::Blocks and click on ‘Settings’ → ‘Complier and Debugger...’.
2. A window labelled Compiler and debugger settings will open as shown in Figure 69.
3. By default the selected compiler is ‘GNU GCC Compiler’. Click ‘Copy’ highlighted with red box
in figure 69.
4. A window as shown in figure 70 will open. Write ‘simplecpp’ and click ‘Ok’.
36
5. A message stating ’change the appropriate setting in Toolchain executable’ is displayed, which is
shown in figure 71.
6. Click on ‘Toolchain executables’ tab highlighted with red box in figure 69.
7. Change the compiler path of Code::Blocks to that of simplecpp. The steps are given below.
8. Click all ‘...’ buttons highlighted with red box in figure 72) on by one. Change all the settings as
shown in figure.
9. When ‘...’ is clicked, browse to the ‘/simplecpp’ directory as shown in figure 73. ‘s++’ and
‘makes++’ are available in ‘/simplecpp/’ folder. ‘libsprite.a’ is available in ‘/simplecpp/lib/’ folder.
10. To summarize, the list of all the fields that need to be changed is given below
(a) Compiler’s installation directory: /simplecpp/
(b) C compiler: /simplecpp/s++/
(c) C++ compiler: /simplecpp/s++/
(d) Linker for Dynamic libs: /simplecpp/s++/
(e) Linker for static libs: /simplecpp/s++/libsprite.a
(f) Make program: /simplecpp/makes++/
37
Figure 73: Simplecpp’s directory
11. When all the required fields are changed, click on ‘Additional Paths’ shown in red block in figure 72.
12. In Additional Paths click ‘Add’ as shown in Figure 74. Browse to /simplecpp/ directory and click
on Ok. User will return on Compiler and debugger setting window. Click Ok again to exit settings
and return to editor.
38
4.5 Writing a new c/c++ program
1. Click on New file button. The ‘New from template’ window opens as shown in figure 75. Select
the type of project you want to program in. When the type of project is selected the Go button
gets highlighted (top right corner). Select ‘Console application’ and click on ‘Go’.
2. When Go button is clicked, a new window opens as shown in figure 76. This window enables the
user to select the required language to proceed. Select the language and click on next.
39
3. The subsequent windows enable the user to provide title for the project and the folder where user
wishes to create the project in. This is shown in figure 77. After filling in the details click ‘Next’.
4. Next window is to select the compiler. By default ‘GNU GCC Compiler’ is selected. In this window,
the user can change the compiler to be used as per the use and requirements.
Non-graphic and Programs including graphics.h header file: Select ‘GNU GCC Compiler’
(figure 78)
Simplecpp programs: Select ‘Simplecpp’ (figure 79) . Click on Finish.
40
Figure 79: Selecting simplecpp for projects including simplecpp
5. Now, the project node opens in manager window as shown in figure 80. Project node can be
expanded to see the main.c file.
41
When main.c file is clicked, it opens in editor as shown in figure 81 for hello world project.
Figure 81: Project Node when Expanded for helloworld.c (with code shown in editor)
Figure 82: Project node when expanded for line.c (with code shown in editor)
42
7. Code used for simplecpp program (3poly) is shown in figure 83. Every project involving simplecpp
has to include simplecpp package as seen in first line of the code.
Figure 83: Project node when expanded for 3poly.cpp (with code shown in editor)
8. While using Code::Blocks for the first time, some extra windows will be displayed. In this manual
only the important windows are shown.
43
Now the project using graphics.h (line) has to be linked with libraries copied in /usr/lib while installing
libgraph package. The steps to link the libraries and build the project is given below.
1. Right click on project node in Manager box and select build options... A new window ‘Project build
options’ as shown in figure 85 pops up. Option to change the compiler selected for the project is
also available in this window.
2. In ‘Project build options’ window, click on linker settings tab. This tab is shown in figure 86.
44
3. In linker settings tab click on Add button under Link libraries box. When Add button is clicked a
small window titled Add library opens as shown in figure 87.
4. Click on dotted button to right of box. A new window opens as shown in figure 88.
This window enables user to browse to appropriate folder and to select required library. Browse to
the /usr/lib directory. All the required library files are not visible.
Select all files in dropdown placed at the bottom, to enable visibility of all types of files.
Select all the libgraph .* files, except libgraph.la file. Files to be selected are shown in the figure 88.
45
5. Libraries shown in Ubuntu 12.04, 32-bit OS are libgraph.a, libgraph.so, libgraph.so.1, libgraph.so.1.0.2,
libgraph.so.4 and libgraph.so.4.0.0. In Ubuntu 12.04, 64-bit OS libraries libgraph.so.4 and lib-
graph.so.4.0.0 are not available. Select all the libgraph.* files except libgraph.la
6. After selecting all the required libraries click on Open. A new window labelled ‘Question’ will open
asking ‘Keep this as relative path’ as shown in figure 89. Click on No.
7. The libraries will be linked using absolute path as shown in figure 90. Click on ‘Ok’.
46
8. We are now re-directed to linker settings tab. The added libraries are shown. In Other linker
options window write ‘-lgraph’ . The final setup is shown in figure 91 with all the required 6
libraries and ‘-lgraph’. Click on ‘Ok’ to get back to editor. Now we are ready to build the project
with graphics.h header file
9. Now click the build and run button from compiler bar and output will be displayed as shown in
figure 92.
47
4.6.3 Graphics Project using simplecpp
To build a program involving simplecpp, it is recommend to enable full logging in Code::Block. Full
logging also helps in better debugging. Steps to enable full Full logging in Code::Block is given in
appendix ??
Click the build and run button from compiler bar and output will be displayed as shown in figure 93.
48
4.7 Opening Existing Program/Project
Click File and select ‘Open’. Browse to desired directory and select the file with .cbp extension as shown
in figure 94 and click on Open.
Figure 94: Select file with .cbp extension to open an existing project
49
References
[1] The Code::Block Team. Code::block homepage
http://www.codeblocks.org/.
[2] The Code::Block Team. Gpl v3.0 license
http://www.codeblocks.org/license.
50