[an error occurred while processing this directive]
[an error occurred while processing this directive]

Cygwin

Cygwin is a collection of POSIX libraries, GNU development tools, and applications. To install Cygwin in Windows, visit http://www.cygwin.com and follow the link Install or update now!. This will download the setup.exe file which you can execute.

First, you will probably want to keep the default Install from Internet. The installation directory should be kept as C:\cygwin\ and you will need a temporary directory to store your installation files.

The next significant window you will see is the Choose Download Site dialog. UW students should probably choose either ftp://mirror.csclub.uwaterloo.ca or http://mirror.csclub.uwaterloo.ca.

The next window is the set of all possible packages which you can install. These are grouped into 29 categories:

  • Accessibility
  • Admin
  • Archive
  • Audio
  • Base
  • Database
  • Devel (Development)
  • Doc
  • Editors
  • Games
  • Gnome
  • Graphics
  • Interpreters
  • KDE
  • Libs
  • Mail
  • Math
  • Mingw
  • Net
  • Perl
  • Publishing
  • Python
  • Security
  • Shells
  • System
  • Text
  • Utils
  • Web
  • X11

If you open one of the categories, you will notice a number of headings:

  • First, under New, you will see the status of the installation for that package.
  • The two headings Bin? and Src? indicate the download status of the binary code and source code for the package, respectively.
  • Finally, on the right, you will see the name and description of the package.

The default for many packages is Skip which indicates the package will be skipped in the installation. Alternatively, you can click on that column which will iterate through the possible versions you can install. By default, one click selects the most current version.

The g++ compiler, by default, is not installed. Consequently, you will have to prompt the Cygwin Setup to include g++, as well as a few other files, in your installation, including:

  • Devel → gcc-g++: C++ compiler
  • Devel → make: The GNU version of the 'make' utility
  • Editors → gvim: GTK interface to the Vim text editor
  • Editors → vim: Vi IMproved - enhanced vi editor
  • Math → octave: The GNU Octave language for numerical computations
  • Shells → tcsh: TENEX C Shell, an enhanced version of Berkeley csh

You may notice that there are dependencies: selecting gcc-g++ will automatically include other packages. You can always relaunch Setup and add or remove packages.

Selecting Next starts the installation process. The reasonably minimal installation described above is 0.954 GiB, however, it occupes 1.107 GiB of hard drive space due to block size (see the topic on B-trees for a full explanation).

There are two means of accessing the installed libraries, tools, and applications:

  • Launch the Cygwin Bash shell, or
  • Set the PATH Environment Variable and use the Command Prompt.

You must set the PATH Environment Variable to be able to access g++ from anywhere.

Cygwin Bash Shell

This is a Unix/GNU-Linux style of prompt which, in my case, puts me into the directory /home/dwharder. The location of the root directory / is in C:\cygwin, however, to access your C: drive, you must connect through the directory /cygdrive/c/. Essentially, the Cygwin Bash Shell completely simulates a Unix/GNU-Linux—like environment.

$ pwd
/home/dwharder
$ ls
Cygwin.bat  Cygwin.ico  bin  cygdrive  dev  etc  home  lib  proc  tmp  usr  var
$ ls cygdrive
c     d
$ cd cygdrive/c
$ ls
$Recycle.Bin            IO.SYS         System Volume Information  doctemp
AUTOEXEC.BAT            Intel          Users                      Epson
Boot                    MSDOS.SYS      Windows                    hiberfil.sys
Config.Msi              MSOCache       bootmgr                    pagefile.sys
DELL                    PerfLogs       config.sys                 watcom-1.3
Documents and Settings  Program Files  cygwin
Drivers                 ProgramData    dell.sdr

One directory of interest is the /bin (actual path: C:\cygwin\bin). In Windows, the directory Program Files contains one directory for each application and each directory contains one or more executable. In Unix/GNU-Linux, most executable are stored in the /bin directory. If you install Linux on your home computer, you may also find executable in /usr/bin and /usr/local/bin, however, all useful executable in Cygwin are located in /bin.

Setting the PATH Environment Variable

When you type a command at the Command Prompt in Windows or in Unix/GNU-Linux, the operating system looks for that command in a restricted number of locations, namely, all directories which are listed in an Environment Variable PATH. Consequently, if you install cygwin, you are not able to, by default execute g++. You could, for example, always type

C:\Documents and Settings\dwharder>\cygwin\bin\g++ Single_list_int_driver.cpp
C:\Documents and Settings\dwharder>

however, this is likely to become frustrating. Instead, it is easier to include the C:\cygwin\bin directory in your PATH. First, launch the Control Panel and do a search for the words Environment Variable. This should bring up a single link to Changing Environment Variables. Selecting this link brings up the System Properties dialog with the Advanced tab selected. At the bottom of this dialog is the Environment Variables... button.

The Environment Variables dialog has two panels. It is probably easier to change the System variables. Search through the list of variables and find one named PATH, Path, or path. If it exists, edit it and append ;C:\cygwin\bin to the list of directories. If it does not exist, create a new variable with the PATH name and set the value to C:\cygwin\bin.

Now, when you launch the command prompt, you can run any of the Unix/GNU-Linux commands, for example

C:\Windows\System32>pwd
/cygdrive/c/Windows/System32
C:\Windows\System32>cd \Users\dwharder\Documents
C:\Users\dwharder\Documents>vim hello.cpp
C:\Users\dwharder\Documents>g++ hello.cpp
C:\Users\dwharder\Documents>a.exe
Hello

At this point, Eclipse will be able to use both the GNU-Linux make utility and the g++ compiler.

[an error occurred while processing this directive]