CS 194-2: Cygwin installation guide


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.


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:

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.


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.

  1. Go to Cygwin's website
  2. Click on the link that says "Install Cygwin now." Save setup.exe on somewhere on your computer (preferably not on a floppy)
  3. Run setup.exe. A window should appear that says "Cygwin Net Release Setup Program"
  4. Click on 'Next'
  5. Select 'Install from Internet'
  6. Click on 'Next'
  7. Make sure 'Root Directory' is 'C:\Cygwin' and 'Default Text File Type' is 'UNIX/binary'
  8. Click on 'Next'
  9. Do not modify 'Local Package Directory' field and click on 'Next'
  10. Click on 'Direct Connection' on the 'Select Your Internet Connection'
  11. Click on 'Next'
  12. 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.
  13. After you select a mirror, click on 'Next'
  14. Wait for the setup program to download 'setup.bz2.' When it finishes downloading you should see a screen titled 'Select Packages'
  15. Click the '+' next to 'Devel', to select packages for developing software (such as compilers).
  16. 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': If you find something else here that looks useful, let me know and I'll include it here as an option.
  17. You may also want to download Cygwin's text editors:
  18. Click on 'Next'
  19. Go fetch a coffee or something while it all downloads.
  20. If you see 'Create Icons', leave the checks under it as is.
  21. Click on 'Finish'

Verifying the install

You've installed Cygwin; the rest of this is to make sure that it installed correctly.

  2. 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.
  3. Close the 'bash' window
  4. Open the following folder:
  5. Find 'startxwin.bat', right-click and select 'Create Shortcut'
  6. 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.
  7. 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
       %  which gdb
       %  which 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.
  8. You're done! Celebrate your nerd prowess with a frosty beverage of your choice, and get coding!

Some Cygwin basics