Back to main

Using the lab software

In these labs, we use gcc (the GNU Compiler Collection) on cygwin (a unix-like environment for windows). This term (spring 2010), you can find cygwin under:

Start menu → Electrical Engineering → Introductory Programming → cygwin

First time

Listing contents of a directory

To see a list of files in a directory (or folder), type:


followed by <enter>. (all these commands must be followed by an <enter>)

New directory

To make a new directory (here called "cpractice", use:

mkdir cpractice

Change directory

To change (move) into a directory, use:

cd cpractice
To change to the directory one level up (i.e. the opposite of cd cpractice, use:
cd ..

Compile a source file

When we program, we write source files. A computer cannot run these directly; it must first compiler it into an executable file (sometimes called an executable binary.

This example assumes that we have created a file called "p1.c" (short for "practice 1 as a C file").

gcc -o p1.exe p1.c
Don't confuse pl (lower-case PL) with p1 (lower-case P one)!

Running an executable binary

After the executable has been created, we can run it with:


Some lab computers will be able to run p1.exe directly, but if that doesn't work, use ./p1.exe

Don't confuse pl (lower-case PL) with p1 (lower-case P one)!

Running previous commands

You'll probably want to re-run a lot of commands you've already typed in. The shortcut is to press the UP arrow; this goes through your command history.

Copying files

To copy a file, use:


(replace UPPER-CASE as appropriate)

Summary of commands

Replace the UPPER_CASE text with whatever is relevant.

mkdir DIR
cd DIR
cd ..
gcc -o OUTPUT.exe INPUT.c

File names

You can name files whatever you want, but keep the .c extension for C source files and .exe for executables.

I recommend that you avoid having spaces in filenames, but if you really want to use them, you can still use that file by typing an escape character of \ in front of any spaces.

Text editors

You may use any text editor you want. The old labs suggested emacs, but this is a very difficult editor to learn. For the first week or two, you might prefer to use the standard Notepad text editor that comes with Windows.

I've heard good things about Notepad++ and jedit (both open-source and free to download+share), but I haven't used them myself so I can't fully endorse them. You should be able to install these programs to your H: drive.

It's worth spending a few minutes to set up your editor -- you will spend a lot of time in it, so make sure you're comfortable!

Creative Commons LicenseUnless otherwise noted, all materials on these pages are licenced under a Creative Commons Licence.