TABLE OF CONTENTS (HIDE)

Cygwin & MinGW (for Windows)

How To Install and Get Started

How to Install Cygwin

Cygwin (pronounced as SIG-win) = GNU + Cygnus + Windows. The mother site for Cygwin is www.cygwin.com.

According to the developers, "Cygwin is a Open-source Linux-like environment for Windows. It consists of two parts:

  • A DLL (cygwin1.dll) which acts as a Linux API emulation layer providing substantial Linux API functionality.
  • A collection of tools which provide Linux look and feel."

To install Cygwin:

Step 1: Download Setup
Download the setup program "setup.exe" from www.cygwin.com.

Step 2: Run Setup to Select, Download & Install Cygwin Packages
Run "setup.exe" ⇒ Install from Internet ⇒ select a directory (avoid installing in "Program Files" because of that "blank" character) ⇒ choose "Local Package Directory" which saves the downloaded installation files ⇒ select your Internet proxy setting ⇒ choose a download mirror site. (If "choose download site" box is empty, add "ftp://mirror.averse.net/pub/cygwin" in the "User URL". You can find all the mirror sites from http://cygwin.com/mirrors.lst.)

Select the packages that you wish to install.

Important: For programmers, you certainly need to open the "Devel" (Development) category and select "gcc", "g++", "gdb", "make", and others, which are not part of the default selection.

Browse thru all the categories. Complete the installation process. You can always re-run "setup.exe" to install additional packages later.

Step 3: Setup PATH
Include the Cygwin Binary directory (bin) in the PATH environment variable.

Suppose that your Cygwin is installed in directory "c:\cygwin". From "Control Panel" ⇒ System ⇒ (Vista only) Advanced System Settings ⇒ Advanced ⇒ Environment Variables ⇒ System Variables ⇒ Select variable named "PATH" ⇒ Edit ⇒ Add "c:\cygwin\bin;" in front of the existing PATH entry. Note that the semi-colon serves as the directory separator to separate Cygwin from the rest of directory paths.

Step 4: Verify Cygwin
Start the Cygwin Command shell (bash or sh) by running "cygwin.bat". You shall see the command prompt "$". You may need to create the users' group and password files by running the following commands:

$ mkpasswd –l > /etc/passwd
$ mkgroup –l > /etc/group

Try out some Unix commands (you need to read a Unix book - there is no short-cut in learning), e.g.,

$ ls
$ dir
$ pwd
$ cd newdir
$ cd ..
$ cd /
List the current directory
Similar to "ls"
Print (or display) the current working directory
Change current working directory to newdir
Change current working directory to its "parent" directory
Change current working directory to its "root" directory

Need help? Try:

$ man command
$ man –k keyword
$ man –f command
$ whatis command
$ info command
$ help
Display the manual pages for command
Display commands containing keyword
Display a brief description of command
Same as "man –f command"
Display the information pages for command
Display the help menu

On bash shell, after setting the directory to the the "root" (via "cd /"), you could find a directory called "cygdrive" (via "ls" or "dir"), where all the hard disks are mounted. "cd cygdrive" and "ls" lists all the hard disks, e.g., "c", "d", etc.

You may mount your C drive ("c:") as "/c" instead of the default "/cygdrive/c" via this command:

$ mount c: \c
$ mount
Mount Drive "C:" as "\c"
Display the current mounts

You could invoke the Cygwin programs and utilities via the Windows' Command Prompt ("cmd.exe") instead of bash shell (provided the PATH is set properly), e.g.,

> ls -alR
> man gcc

How to install MinGW

MinGW (short for "Minimalist GNU for Windows"), is a minimalist (i.e., small but fewer features compared with cygwin) development environment for native Microsoft Windows applications, in particular:

  1. A port of the GNU Compiler Collection (GCC), including C, C++, ADA and Fortran compilers;
  2. GNU Binutils for Windows (assembler, linker, archive manager).
  3. MSYS (short for "Minimal SYStem"), is a bash Shell command line interpreter.

To install MinGW:

  1. Goto MinGW mother site at http://www.mingw.org/ ⇒ Downloads ⇒ Installer ⇒ click on "mingw-get-inst" link to download the installer.
  2. Run the downloaded installer.
    1. Set the installation directory. (Try to use a directory name without spaces, e.g., "d:\myproject\mingw". Try not to install under "Program Files" or "Desktop".)
    2. In MinGW Installation Manager, select "Installation" ⇒ "Update Catalogue" ⇒ Select all packages in "Basic Setup" ⇒ continue.
  3. Setup environment variable PATH to include "<MINGW_HOME>/bin" where <MINGW_HOME> is the MinGW installed directory that you have chosen in the previous step.
  4. Verify the GCC installation by listing the version of gcc, g++ and gdb:
    > gcc --version
    g++ (GCC) 4.8.1
    ......
     
    > g++ --version
    g++ (GCC) 4.8.1
    ......
     
    > gdb --version
    GNU gdb (GDB) 7.6.1
    ......

Writing C/C++ Programs using GCC in Cygwin or MinGW (under Windows)

Read "GCC and Make".

REFERENCES & RESOURCES

  1. Cygwin Mother Site @ www.cygwin.com.
  2. MinGW mother site @ www.mingw.org.