Cygwin

Installation
Using Cygwin

The Cygwin (http://www.cygwin.com/) package provides a Unix-on-Windows compatibility package. This lets you use the Unix commands we saw in class. You enter your commands into a Cygwin window, just like we do in class.

Installation

Installation of Cygwin is not difficult. Start by going to http://www.cygwin.com/ and clicking on the "Install Cygwin now" link (marked with the ).

This will download a setup.exe program; if you are using Windows 98, Internet Explorer may suggest saving the file into "My Download Files". This default is fine, or you may choose another folder. Please do not download it to your desktop! Press the "Save" button, and wait for the program to download.

Once setup.exe has finished downloading, open it. Then follow these easy steps:

  1. A copyright page appears; press the "Next" button.
  2. Select "Install from Internet", then click the "Next" button.
  3. You should next see a panel with an entry for "Select install root directory". The default is C:/cygwin, which is fine. The default text file type can be "Unix", and the "Install For" can be "All". The click "Next".
  4. Next, you will see see a "Local Package Directory" screen. Take the default (often >C:\My Download Files), unless you know what you are doing and another location seems more reasonable to you for your system. Then click "Next".
  5. On the next screen, you have several choices on how to download Cygwin from the internet. Choose "Use IE5 settings" (although you can probably also use "Direct Connection"). Then click "Next".
  6. Now you get to the "Select download site". In theory, any of these could be used. I've had good success with http://mirrors.kernel.org.
  7. Now you'll see a rather complex page asking you to mark which packages should be installed. There is a column on the left labelled "Category"; one of the categories in labelled "Devel". Click on the word "Devel", and it should expand into a list of component packages.
  8. Final screens: Yes, you'll want the desktop icon, and the addition to your start menu, so leave these options marked.. Then click "Next". Finally, a message window will appear saying "Installation complete"; just press the "OK" button to close it.

Using Cygwin

On Windows, you can enter operating system commands using a "DOS Shell" window. On Unix or Linux systems, one enters operating system commands in a "terminal emulator" window. Cygwin gives you something in between. It allows you to enter Unix commands, as well as some Windows commands, on a Windows system. Most important for our course: Cygwin provides the gcc command for compiling programs.

If you choose, you can use notepad instead of xemacs to edit your programs. For instance, if you want to edit hw.c with notepad, you would enter the command:

notepad hw.c &

The first time, it may tell you that hw.c does not exist, do you want to create it? Of course you do...

You can compile your programs using the gcc commands:

gcc -ansi -pedantic -Wall hw.c

The programs it creates is called a.exe. To run this, you must type:

./a.exe

To print your program, you can use notepad's print option. Cygwin does not provide the script command, found on other Unix systems, so there is no easy way I know of to capture the output of running a C program. You may want to submit your program as an email attachment.


Beginning C Programming for Engineers


R. Lindsay Todd
Rensselaer Polytechnic Institute