Home Page

Compiler & Editor:
Installation To 1st Program


Overview

In order to program in C you need to have both a text editor and an ANSI-C compatible compiler/linker. Many are available on the Internet -- some are free while others have licensing requirements. In addition, a number of companies have created Integrated Development Environments (IDE) which combine the compiler and text editor into one package. An example of an IDE is Arduino which combines a text editor with the gcc compiler/linker for C language in one package.

As you you download and install the text editor and gcc compiler/linker, you may want to follow along with our instructional video youtube logoas our class goes step by step through the installation answering questions as we go.

We assume you are using a computer that uses Microsoft Windows as the operating system. If you are using Linux, the compiler and editor are already installed on your computer.


Text Editor

Why do I need it?

For writing programs you need a text editor. Windows includes a text editor with the operating system called "Notepad". It is important to note that a text editor is not the same as a word processor (i.e. Microsoft Word). A word processor deals with the preparation of documents for printing. Besides editing text, a modern word processor allows the user to choose multiple fonts, margin sizes, line spacing, indentation, and a variety of other details that affect the appearance of the document being edited. (These additional details are encoded in characters that are not seen on the user screen.)

In a text editor, these features are absent. A text editor is an application that edits files containing plain text without information regarding formatting. Typically, the contents of such a file consist of data used by another application, for example, source code that a compiler will process or mark up text that a web browser will display. In place of word processing features, a text editor may contain features that allow the user to prepare and work with text quickly and efficiently, for example, displaying comments and ANSI-C key words in different colours. There are many free text editors available on the Internet.

What text editor should I use?

Microsoft windows has a built in text editor called Notepad which one could use to display only the text in the file. A better choice, for programming would be a text editor that recognizes sequences of characters that have significance in the computer language in which you are writing your program.

Notepad++ is an free editor (for Microsoft Windows) that has been designed to work with over 80 computer programming languages (including ANSI-C and Java, javascript). Once you have mastered it in ANSI-C, you will be able to use the same editor to prepare your programs,no matter in what language you decide to program: c, html, javascript, css. The following figure compares how the same C-code file is presented in notepad and in notepad++

notepad    notepad++
Which do you think is easier to check for errors?

Install Notepad++

  1. Download Notepad++
  2. Accept all default suggestions

Compiler/Linker

head of gnu

Why do I need it?

Once you have written your program you need to use a compiler to translate your words into binary machine code that the computer can understand. In addition, you also need to link your functions with functions written by other people (There is no point to reinvent the wheel!). For example, if you are programming Arduino, then probably 99.9% of the code has been written by other people! You just need to incorporate their work into your program.

What compiler/linker should I use?

If you are using UNIX or LINUX then the Gnu Compiler Collection (gcc) is already installed on your computer -- you do not need to do anything. For windows users, I suggest MinGW port of gcc as it is one of the best supported free compilers. (Another port of gcc is the one used for Arduino, and it includes the text editor together with the compiler.)

Install MinGW port of gcc

gnu gcc
  1. Navigate to MinGW homepage
  2. Click the big Download Button
  3. Execute the file (run the installer)
  4. Under the Basic Setup Tab select mingwXX-base -- A basic MinGW Installation
  5. Under the Menu Item Installation, choose Apply Changes
  6. After installation finishes change the directory name from c:\mingw to c:\sdba
  7. Download Course specific files for MS-Windows
  8. Place the contents of this unzipped file into the directory c:\sdba
  9. (If windows cannot recognize the file extension zip, download 7-zip and install 7-Zip. You can use this program to extract the files.)

Compile, Link, & Run Program to Verify Successful Install

  1. Click on Ansi-C/SDBA Icon (top page for image) c:\sdba. This should open a console (command) window in the directory c:\sdba.
  2. Compile the program " welcsdba.c ", Type: gcc -c -ansi welcome.c
  3. Link the program " welcsdba.c " with the library function fprintf(), type gcc -o welcome.exe welcome.o
  4. Run the Program, type: welcome to get a welcoming message.

Move ANSI-C icon to desktop (beside Notepad++)