InstallingCodeBlocks (1)
InstallingCodeBlocks (1)
The IDE is called Code::Blocks (version 10.05). (See http://www.codeblocks.org/ if you want
more information.)
The compiler is the MinGW port of the Gnu Compiler Collection (version 4.4.1). (See
http://www.mingw.org/ if you want more information.)
The prescribed software is designed to work on Windows platforms (e.g. Windows XP, 7 or
8), but there are versions available for other operating systems, like Linux. Although you are
welcome to use other versions of the software, we will not be able to give you any support if
you don't use the prescribed software. Also, you must make sure that the programs you
submit for your assignments work on the prescribed software.
In COS1511, the programs you write will be somewhat simpler than for COS1512. In
particular, all the programs will consist of a single file, so you can get by without a project.
To help you get started we present a short guide to your first "Hello World" program.
Open Rubric
Step 1. Start Code::Blocks
During installation, a shortcut to Code::Blocks should have been placed on the desktop.
Double-click it to start Code::Blocks.
Otherwise, you can click on the Windows "Start" button and choose "CodeBlocks" on the
"Programs" submenu.
To create a source file, choose "New | Empty File" on the "File" menu, or click on the "New
File" toolbar button and choose "Empty File" on the pop-up menu. An empty source file will
be displayed in the edit panel:
By the way, you can hide the Project manager (the panel on the left) by deselecting
"Manager" on the "View" menu, or by clicking on the close button (little cross) on the
"Management" panel. You won't be needing this for COS1511.
Choose "Save" or "Save as" on the "File" menu, or click on the "Save" toolbar button. We
suggest that you create a separate directory (such as C:\unisa\COS1511) in which you save
all your work for a particular module. Beware: Do NOT save it in a directory (or a path) with
a space in it (such as C:\My Documents\COS1511). Navigate to the directory you've created
(if necessary) before typing the name of the source code file, e.g. first.cpp, and clicking on
the "Save" button.
The only difference you should notice is that the filename *Untitled1 has now been replaced
by your filename, e.g. first.cpp.
It may seem strange to save a file before you have typed a program, but it is a good habit to
get into.
Step 4. Edit the source file
This is the easy part. Choose "Build" on the "Build" menu, or click on the "Build" toolbar
button. Watch the messages displayed in the "Build log" below the edit panel.
Assuming you haven't made any typing mistakes, your program should compile without any
errors. (If there are errors, they will be displayed in the "Build log".)
If you are SURE that you have typed in the program precisely correctly, but an error message
is displayed every time you compile the program, see Troubleshooting below.
This is the fun part. To see the fruits of your labour, either choose "Run" from the "Build"
menu or simply click on the "Run" toolbar button. If all goes well you should see a window
like this:
Press any key to close the console window.
Congratulations! You have just compiled and run a C++ program using Code::Blocks. Easy,
wasn't it?
To create a new program, close your existing program, and open a new one. To edit an
existing program (one that you worked on previously), choose "Open" on the "File" menu or
click on the "Open" toolbar button.
Troubleshooting
Make sure that your source code file is not saved in a directory (or a path) with a space in it.
We recommend that you create a directory, e.g. C:\unisa\COS1511, and save all your source
code files there.