Skip to content
Physics and Astronomy
Home Our Teaching Resources C programming codeblocks.html
Back to top

C programming on your Linux or MS Windows laptop

For a programming environment under Linux or MS Windows we now recommend using the same system we will be using during classes, Code::Blocks. This is free software.

Downloads

Once you are on the Code::Blocks web site the easiest way to download it is to just choose the Downloads ... Binaries link from the left-hand sidebar.

NB: when installing Code::Blocks put it ito a folder whose name does not contain spaces or other "funny" characters. Use a folder name that would be a legal C variable name! (Although feel free to use capitals.)

MS Windows version

These are normally a two or three possible downloads and it's important to use the right one. Look for the IF UNSURE advice.

Using Code::Blocks

1. Click on Create a New Project (also available from the File > New... menu) and choose Console Application

2.Choose the "C" language

(NOT "C++").

3. Choose where to store your project.

We suggest you create a folder "PHY2027" and put all your projects inside there.

Where to save your project on Harrison clusters

On the Harrison lab computers do not save your project to the "Network" folder. Instead, if you go into the "Computer" folder you should see the "Personal Filespace (U)" drive. Create your "PHY2027" folder inside there:

When you use a PC in the forum etc you will find your files there.

4. Choose a sensible Project name

NB: I have had trouble when I have typed a folder name in the "Folder to Create Project" box. if this happens to you, use the Folder Selection just by it to choose a folder. be sure to choose a folder inside your home space, again with a space-free name.

"main.c" appears inside the "Sources" folder.

Compiler options

We strongly recommend using the same compiler settings as we are using in-class. You should only need to do this once for it to apply to all projects. NB: these are already set on our machines, but you will need to set them up if you have installed Code::Blocks yourself.

To set your compiler options

Go to the "Settings" menu and choose "Compiler".

An panel such as this should appear:

It should open showing the "Compiler settings" tab and the "Compiler Flags" sub-tab. Click on the checkboxes for:

-g
-Wall

(Note that the options appear at the end of the line of text for each option.)

Other options sub-tab

Now click on the "Other options" sub-tab and manually enter:

-std=gnu99
-Werror
                                                                                                                                                                                                                                                                       

Validate   Link-check © Copyright & disclaimer Privacy & cookies Share
Back to top