There are a few things which we will be using often in this course; it is imperative that you have had them set up when we use them.

Please ensure that the following are ready to use by the first lesson:

  • An IDE and compiler for your language of choice

  • A wcipeg account, for challenging practice

The latter point is rather trivial; the rest of this "lesson" regards the setup of an IDE for C++.

An IDE for C++

Code::Blocks is a nice, minimalistic cross-platform IDE for C++. It is very useful for small programs — contest submissions — and, with some extra work, will support large projects.

It can be downloaded here.

Note

The Mac/OS-X version of Code::Blocks is outdated.

You may wish to use a C++ Shell instead.

Important

There are six download links for the Windows version of Code::Blocks.

Make sure that you are downloading a 16.01mingw version, as those include the GCC Compiler!

Using Code::Blocks

If you are running Code::Blocks on Mac OS-X, you may be urged to download a command line. Allow Code::Blocks to install the command line.

Test that Code::Blocks is working by creating a new C++ file selecting File -> New -> Empty file, or with Ctrl+Shift+N. Save this file with File -> Save or with Ctrl+S with the file extension .cpp.

Important
Files will normally save as a C Source file with the .c extension. However, we are working in C++; your file must use the .cpp extension, or it will not be compiled as a C++ Source!

Copy and paste the following code into your empty file:

helloworld.cpp

1
2
3
4
5
6
7
#include <iostream>

int main(int argc, const char* argv[])
{
    std::cout << "Hello World!" << std::endl;
    return 0;
}

In a toolbar at the top of your screen, you will see a button which looks like a green triangle (Run) next to a button which looks like a yellow gear (Compile). Next to those two buttons is a button with both. This is the Compile and Run button; click on it, and wait for your program to compile and run.

If this is the first time you’re using Code::Blocks, it should fail. On the menu bar, select Settings -> compiler…​ and a little screen should pop up.

On the Global compiler settings tab, choose the GNU GCC Compiler for the Selected compiler, and then click on Reset defaults at the right.

After that, try compiling and running your program again. A black window should pop out with the text Hello World!, and you are now ready to continue.

Doesn’t work? Google is your friend! Welcome to Computer Science.