CS 194-2: Cygwin installation guide
Credits
This Cygwin installation guide was adapted from a
similar guide written for CS 61C. I've made a few cosmetic
changes. All trademarks listed here, including Unix, Windows, and
Solaris, are copyrighted by their respective owners.
What is Cygwin?
Many students who run Windows on their home computers would like the
ability to do their CS 194-2 assignments from home without going to or
connecting to the labs. As a result, the following are instructions to
install Cygwin, a Unix-like environment for Windows.
Cygwin is more than just a command-line shell. It extends your
Windows system to conform more or less to the POSIX
standard. This standard specifies a common set of features that
Unix-like operating systems should provide. This includes the
shell command line (with functions like 'ls', 'cd', and 'rm'),
standard command-line utilities (such as 'awk' and 'grep'),
applications for development (such as C compilers and linkers, and the
'make' utility), and APIs for various system functions. Cygwin favors
a GNU/Linux-like flavor of POSIX, and so it provides the standard
suite of GNU tools and extensions, including familiar text editors
like Emacs and Vim.
Benchmarking
The main point is that Cygwin gives you the POSIX Pthreads API, and
the compiler, linker, and libraries you'll need to build and run
Pthreads programs on a Windows machine. This means you can code and
debug on your own machine. As for benchmarking -- I really don't
know how well it will do, and I'm curious to find out!
Presumably Cygwin's Pthreads implementation is built on top of
Windows' own native threads, but I don't know that for sure. You
are welcome (and, in fact, encouraged) to report benchmark results
for Cygwin: if you do so, please include the following information:
- Version of Cygwin
- Version of Windows
- Computer hardware specs (incl. number of processors/cores)
- Did you have other programs open? (MP3 players take a lot of
CPU cycles, for example, so they will probably mess with your
benchmark results.)
Caveat lector
Let the reader beware! I have not used Cygwin for development
since 2002. I do not have access to a Windows machine on which to try
out these instructions, and I won't buy or pirate a copy of Windows to
do so. You'll have to help each other on this one. If you find
mistakes in these instructions, or have further suggestions, please
contact me so I can post them here.
Note also that all assignment are tested and graded by running them on
the cluster machines to which we have access. You must verify your
project works on one of these platforms, and also tell us on
which platform(s) it is known to work. It is not good enough to
say that your assignment worked under Cygwin/Windows. The staff
will not grant assignment extensions (or grace periods) because of
porting issues between your home computer and the clusters.
Porting may take a bit of effort, because Cygwin's Pthreads API is
missing certain features that are typically found in Unix-like
pthreads implementations, most notably barriers. Pthread barriers are
an optional extension of the POSIX standard. Some people have written
barrier implementations and posted them online, or you can write your
own, but you'll have to make sure that the code works on the clusters.
Installation
WARNING: These instructions are provided as is. The staff will not
be held responsible for any unexpected behavior of your computer due
to following the directions below.
-
Go to Cygwin's website
-
Click on the link that says "Install Cygwin now." Save setup.exe on
somewhere on your computer (preferably not on a floppy)
-
Run setup.exe. A window should appear that says "Cygwin Net Release
Setup Program"
-
Click on 'Next'
-
Select 'Install from Internet'
-
Click on 'Next'
-
Make sure 'Root Directory' is 'C:\Cygwin' and 'Default Text File Type'
is 'UNIX/binary'
-
Click on 'Next'
-
Do not modify 'Local Package Directory' field and click on 'Next'
-
Click on 'Direct Connection' on the 'Select Your Internet Connection'
-
Click on 'Next'
-
The setup will now download a list of mirrors. You can select any of
them. The smart thing to do is figure out which ones are (a.) closer,
(b.) faster, and (c.) likely not to be not heavily loaded.
-
After you select a mirror, click on 'Next'
-
Wait for the setup program to download 'setup.bz2.' When it finishes
downloading you should see a screen titled 'Select Packages'
-
Click the '+' next to 'Devel', to select packages for developing
software (such as compilers).
-
Make sure the following packages do not have 'Skip' on their lines. If
they have 'Skip', just click on it to change it to something that isn't
'Skip':
- + ddd
- + gcc-core
- + gdb
- + make
If you find something else here that looks useful, let me know and
I'll include it here as an option.
-
You may also want to download Cygwin's text editors:
- Click on the '+' next to 'Editors'.
- Choose at least one of the following packages by making sure
that they don't have 'Skip' on their lines. If the ones you
want have 'Skip', just click on it to change it to
something that isn't 'Skip':
- + emacs
- + emacs-X11
- + vim (or something like this)
- If you selected an editor that says 'X11' in its name, you'll
need to install X11:
- Click on the '+' next to 'X11'
- Make sure the following packages do not have 'Skip' on
their lines. If they have 'Skip', just click on it to
change it to something that isn't 'Skip':
- + X-start-menu-icons
- + X-startup-scripts
- + xorg-x11-base
- + xorg-x11-bin
- + xorg-x11-bin-dlls
- + xorg-x11-devel
- + xorg-x11-xwin
- + xterm
- Click on 'Next'
- Go fetch a coffee or something while it all downloads.
- If you see 'Create Icons', leave the checks under it as is.
- Click on 'Finish'
Verifying the install
You've installed Cygwin; the rest of this is to make sure that it
installed correctly.
-
Restart your computer. (YOU MUST DO THIS OTHERWISE THE FOLLOWING STEPS
WILL NOT DO WHAT THEY ARE EXPECTED TO DO.)
- Double-click the Cygwin icon on your desktop. A 'bash' window should
appear. If you see a ~ in the console prompt, everything is good. If you
don't, then consult a GSI or friend who knows Cygwin.
- Close the 'bash' window
-
Open the following folder:
C:\Cygwin\usr\X11R6\bin
- Find 'startxwin.bat', right-click and select 'Create Shortcut'
- Move the created shortcut to the desktop, and double click on it. An
'X' should appear next to your clock and an 'xterm' window should pop
open. If it does, you are just about done. If not, then consult a GSI
or friend who knows Cygwin.
- Verify you can find gcc, gdb, and (if you installed it) emacs (or
vim) by typing the following in the 'xterm' console. You should get
the following output:
% which gcc
/usr/bin/gcc
% which gdb
/usr/bin/gdb
% which emacs
/usr/bin/emacs
If anything deviates from that, then you probably have not installed them.
Try running setup again, and make sure you selected all the programs
listed in the installation instructions above.
-
You're done! Celebrate your nerd prowess with a frosty beverage of
your choice, and get coding!
Some Cygwin basics
-
A Cygwin or xterm shell provides a Unix-like environment, so
most of what you know from using Instructional Solaris computers
or GNU/Linux machines carries over. In particular, the tilde (~)
means your home folder which Cygwin sets up for you. It's not the
same as your Windows home directory or Desktop. If you want to find
your Cygwin home directory via Windows, you can find it at
C:\Cygwin\home\<username>\
in which <username> is your Cygwin username. If you want to
access your hard drive's root directory in Cygwin, you must cd
(change directory) '/cygdrive', then select your drive based on the
folders listed in '/cygdrive'.
-
If you want to open a(nother) xterm window you can do that by going to
Start->Programs->Cygwin-X->xterm
or you can just type 'xterm&' in an opened 'xterm' window.
-
If you get 'command not found' and it is a POSIX standard command that
you expect to find on Unix-like machines, then it probably wasn't
installed. You can install it yourself; just run the Setup program
again, and when you get to 'Select Package', change the view to 'Full'
and scroll through the packages to find the desired application.
-
One last piece of advice: If you have spent all day getting this to
work and it still doesn't work--STOP! Just use SSH or go to lab. It is
not worth your time to spend several days trying to get this to work
when you could have spent this time doing your assignment in the labs.
Last updated 28 August 2007.