This page tells you how to download, install, and use the freely available C/C++ compiler MinGW. MinGW is a port of the gcc compiler to Microsoft Windows (gcc is the compiler for the Linux operating system). Below are several steps that lead you through the installation. The steps show you how to access the gcc compiler from the text editor TextPad.
- Step 1:
- First you need to download an installer file. This file is fairly large, so you may want to do this download on campus and then transfer the file to either a zip disk or a CD-R disk. Put the file in some temporary location on your computer.
MinGW compiler system installer (12 MB)
- Step 2:
- Now run the installer. Have the installers install your copy of MinGW in the directory
C:\MinGW . Do not install MinGW in the C:\Program Files directory. The space in that directory name can cause all kinds of problems.
- 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 Version 4.6 text editor. 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.8 MB in size).
ftp://download.textpad.com/pub/textpad4.6/txpeng460.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 a few new tools that let us use MinGW (i.e. gcc) from within TextPad.
- Step 6:
- We need to create a tool in TextPad to call the gcc compiler and 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:\MinGW\bin and then in that directory double click on the program gcc.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 "gcc". Click on the item "gcc". This brings up a window where we can configure the "gcc" 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 -o $BaseName.exe $File
In the text box labeled "Initial folder:" enter the following text:
$FileDir
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 "gcc" is at the bottom of the menu list.)
- Step 7:
- We need to create a tool in TextPad that lets us run a program that we have compiled and linked (if you have already done this for lcc, then you can skip this step). 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 8: (optional)
- At this point, the 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?
|