Installing C on your home computer

LCC-Win32 a freely available C compiler (not C++). This page shows you how to install and use this compiler. (You do not need to use this compiler for CS 124.) Below are several steps that lead you through the installation.

LCC-Win32 is not just a C compiler. It is actually a fairly complete IDE (Integrated Development Environment). If you want to, you can use the LCC-Win32 compiler through the IDE. But the following steps show you how to access the LCC-Win32 compiler from outside the IDE by using a programmer's text editor called TextPad as a kind of baby IDE. This way of writing and compiling C programs has some real advantages (mainly simplicity) when you are working on small programs.

Step 1:
First you need to download two installer files. One of these files is fairly large, so you may want to do this download on campus and then transfer the files to either a zip disk or a CD-R disk. Put these files in some temporary location on your computer. (If you need to get started in a hurry, you do not really need the large file. You can get started with just the smaller file.)
LCC-Win32 Compiler System (3.7 MB)
Windows API Documentation (12.8 MB)

Step 1.5 (Optional):
If you want more documentation, you can also download the following two files.
LCC-Win32 User's Manual (2.5 MB)
LCC-Win32 technical documentation (6.6 MB)

Step 2:
Now run the installers in the order that they are listed above. Have the installers install your copy of LCC-Win32 in the directory C:\lcc. Do not install LCC-Win32 in the C:\Program Files directory. The space in that directory name can cause all kinds of problems.

Step 2.5 (Optional):
The LCC-Win32 installer creates a "lcc-win32" program group in your Start Menu. Look in this program group and start the program called lcc-win32. This starts up the IDE. If you wish, read the documentation that comes with the IDE (if you installed the documentation). I will not describe how to use the lcc-win32 IDE. Instead, the remaining steps show you how to use the TextPad editor as a simple IDE.

Step 3:
If you have already installed TextPad on your computer (for use with another programming language), then skip to Step 5. Otherwise, download the TextPad text editor (the current version, at the time of this writitng, is TextPad Version 4.7.2). TextPad is shareware; you can download and use it for free for a trial period, but then you are supposed to pay a shareware fee if you plan to continue using it. Use the following link to download the installation file (which is just over 1.9 MB in size).
ftp://download.textpad.com/pub/textpad4.7/txpeng472.exe

Step 4:
Install TextPad by double clicking on the installer that you just downloaded.

Step 5:
Run TextPad by finding it in your Start Menu. Click on the Tools menu at the top of the TextPad window. Several "tools" are pre-installed by TextPad. We need to install five new tools that let us use lcc-win32 from within TextPad.

Step 6:
We need to create a tool in TextPad to call the lcc-win32 compiler. Click on TextPad's "Configure -> Preferences..." menu item. In the left hand pane of the window that comes up, click on the word "Tools" (don't click on the + next to the word "Tools"). In the right hand pane, click on the "Add" drop down list and choose the item "Program...". In the file dialog box that comes up, navigate to the directory C:\lcc\bin and then in that directory double click on the program lcc.exe. Now you should be back to TextPad's "Preferences" window. Click on the button "Apply" at the bottom of this window. Now click on the + next to the word "Tools" in the left hand pane of the window. Under the word "Tools" you should have the item "lcc". Click on the item "lcc". This brings up a window where we can configure the "lcc" tool. In the text box labeled "Parameters:" enter the following text. (Note: Upper and lower case matter! The best way to enter the text is to use cut and paste from here to the text box.)
-S -c -IC:\lcc\include -g2 $File
In the text box labeled "Initial folder:" enter the following text:
$FileDir
In the text box labeled "Regular expression to match output:" (below all of the check boxes) enter the following text in place of what is currently there:
^\(Error\|Warning\) \([^:]+\): \([0-9]+\)
Make sure that the check boxes labeled "Save all documents first" and "Capture output" are checked. Now click on the button "OK" at the bottom of the window. This completes the creation of the compiler tool. (You can check at this point and look in TextPad's "Tools" menu to see if the tool "lcc" is at the bottom of the menu list.)

Step 7:
We need to create a tool in TextPad to call the lcc-win32 linker. Click on TextPad's "Configure -> Preferences..." menu item. In the left hand pane of the window that comes up, click on the word "Tools" (don't click on the + next to the word "Tools"). In the right hand pane, click on the "Add" drop down list and choose the item "Program...". In the file dialog box that comes up, navigate to the directory C:\lcc\bin and then in that directory double click on the program lcclnk.exe. Now you should be back to TextPad's "Preferences" window. Click on the button "Apply" at the bottom of this window. Now click on the + next to the word "Tools" in the left hand pane of the window. Under the word "Tools" you should have the item "lcclnk". Click on the item "lcclnk". This brings up a window where we can configure the "lcclnk" tool. In the text box labeled "Parameters:" enter the following text:
-subsystem console -o $BaseName.exe $BaseName.obj
In the text box labeled "Initial folder:" enter the following text:
$FileDir
Make sure that the check box labeled "Capture output" is checked. Now click on the button "OK" at the bottom of the window. This completes the creation of the linker tool.

Step 8:
We need to create a tool in TextPad that lets us run a program that we have compiled and linked. Click on TextPad's "Configure -> Preferences..." menu item. In the left hand pane of the window that comes up, click on the word "Tools" (don't click on the + next to the word "Tools"). In the right hand pane, click on the "Add" drop down list and choose the item "Program...". In the file dialog box that comes up, navigate to the directory C:\windows on a Windows 98 computer or the directory C:\WINNT\system32 on a Windows 2000 computer. On a Windows 98 computer, double click on the program command.exe. On a Windows 2000 computer, double click on the program cmd.exe. Now you should be back to TextPad's "Preferences" window. Click on the button "Apply" at the bottom of this window. Now click on the + next to the word "Tools" in the left hand pane of the window. Under the word "Tools" you should have either the item "command" or "cmd". Click on the appropriate item. This brings up the window where we can configure the tool. In the text box labeled "Parameters:" enter the following text:
/k $BaseName.exe
In the text box labeled "Initial folder:" enter the text:
$FileDir
Make sure that all the check boxes are unchecked. Now click on the button "OK" at the bottom of the window. This tool will run your C program one time and then leave you at a command prompt so that you can type other commands (you can use the "exit" command to close the console window).

Note: If your C program does not prompt the user for any input, then you can configure TextPad to capture your program's output and display it in an editor window. Change the text in the text box labeled "parameters:" to

/c $BaseName.exe
(notice that we are changing the switch /k to /c) and then check the check box labeled "Capture output". This technique can be useful for a variety of reasons, for example, you want to save the program's output, or you want an easier way to read a large amount of output, or you are using Windows 98 and the console window does not have a line buffer, etc.

Step 9:
We need to create a tool in TextPad to use the Microsoft Win32 API help file that comes with LCC-Win32. Click on TextPad's "Configure -> Preferences..." menu item. In the left hand pane of the window that comes up, click on the word "Tools" (don't click on the + next to the word "Tools"). In the right hand pane, click on the "Add" drop down list and choose the item "Online Help File...". In the file dialog box that comes up, navigate to the directory C:\lcc\bin and then in that directory double click on the help file win32.hlp. Now you should be back to TextPad's "Preferences" window. Click on the button "OK" at the bottom of this window. This completes the creation of the Win32 API help tool.

Step 10:
We need to create a tool in TextPad to use the C Runtime Library help file that comes with LCC-Win32. Click on TextPad's "Configure -> Preferences..." menu item. In the left hand pane of the window that comes up, click on the word "Tools" (don't click on the + next to the word "Tools"). In the right hand pane, click on the "Add" drop down list and choose the item "Online Help File...". In the file dialog box that comes up, navigate to the directory C:\lcc\bin and then in that directory double click on the help file wedit.hlp. Now you should be back to TextPad's "Preferences" window. Click on the button "OK" at the bottom of this window. This completes the creation of the C Runtime Library help tool.

Step 11:
Now it is time to test TextPad. Use your browser to download and save this very short C program, hello.c, to your computer. Use TextPad to open hello.c. (You can use the "File -> Open" menu item in TextPad; you will need to remember where you had your browser store the hello.c file. Or, you can right click on the file hello.c and choose TextPad from the pop-up context menu.) Use the "Tools -> lcc" menu item to have TextPad run the C compiler. When the compiler tool finishes, use the "Tools -> lcclnk" menu item to have TextPad run the linker. When the linker tool finishes, use the "Tools -> cmd" menu item to have TextPad open a DOS command box at the directory containing hello.exe and run the program hello.exe. After you see the program's output, close the DOS command window and go back to TextPad and double click on the function name printf. Then use the "Tools -> wedit" menu item to have TextPad bring up the C Runtime Library help for the printf function. Close the help window and go back to TextPad. Purposely create an error in the program (delete a semicolon or misspell a name). Try to compile the program. When you get an error message from the compiler, double click on the line number in the error message. TextPad should jump to the line in the C program that the error message referred to.

Step 12: (optional)
At this point, the five tools that we created have pretty unappealing names. You can use the "Configure -> Preferences..." menu item to edit these names by clicking on the word "Tools" in the left hand pane of the "Preferences" window and then clicking on a tool in the middle pane and editing the name of the tool.
TextPad is a very powerful text editor. It has a lot of tools that make working with C, C++, Java, HTML, etc., files very easy. Editors like Notepad really pale in comparison to an editor like TextPad.

When you are editing your C source files, remember to save your work frequently (at least every 15 minutes), otherwise it may be Abort, Retry, Ignore?


Return to the main C++ Programming page.
Return to the CS 124 home page.


compliments and criticisms