TABLE OF CONTENTS (HIDE)

Cygwin64 & MinGW-w64 (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
Goto Cygwin mother site @ https://www.cygwin.com ⇒ Click "Install Cygwin" ⇒ Download the setup program "setup-x86_64.exe" (64-bit Windows) or "setup-x86.exe" (32-bit Windows).

Step 2: Run Setup to Select, Download & Install Cygwin Packages
Run "setup-x86_64.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 ⇒ Direct Connection ⇒ choose a download mirror site.

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" 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" ⇒ (Optional) System and Security ⇒ System ⇒ Advanced System Settings ⇒ "Advanced" tab ⇒ 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-w64 GCC Compiler

[To Check] Is MinGW obsoleted by MinGW-W64, which supports both 32-bit and 64-bit Windows?

MinGW-w64 (short for "Minimalist GNU for Windows") (@ https://www.mingw-w64.org/), 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-w64:

  1. You can install MinGW-w64 via MSYS2 (@ https://www.msys2.org/), which provides up-to-date native builds of GCC, Mingw-s64 and other helpful C++ tool and libraries..
  2. Add "<MINGW_HOME>/bin" to PATH where <MINGW_HOME> is the MinGW installed directory.
  3. 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
    ......

How to install MinGW-w64

MinGW-w64 is a fork of MinGW to support 64-bit Windows (as well as the 32-bit windows). The mother site is http://mingw-w64.org/doku.php.

You can install MinGW-W64 under "Cygwin" by selecting these packages (under "Devel" category):

  • mingw64-x86_64-gcc-core: 64-bit C compiler for native 64-bit Windows. The executable is "x86_64-w64-mingw32-gcc".
  • mingw64-x86_64-gcc-g++: 64-bit C++ compiler for native 64-bit Windows. The executable is "x86_64-w64-mingw32-g++".
  • mingw64-i686-gcc-core: 64-bit C compiler for native 32-bit Windows. The executable is "i686-w64-mingw32-gcc".
  • mingw64-i686-gcc-g++: 64-bit C++ compiler for native 32-bit Windows. The executable is "i686-w64-mingw32-g++".

To check the versions:

// 32-bit Windows
$ i686-w64-mingw32-gcc --version
i686-w64-mingw32-gcc (GCC) 6.4.0
$ i686-w64-mingw32-g++ --version
i686-w64-mingw32-g++ (GCC) 6.4.0
// 64-bit Windows $ x86_64-w64-mingw32-gcc --version
x86_64-w64-mingw32-gcc (GCC) 6.4.0 $ x86_64-w64-mingw32-g++ --version
x86_64-w64-mingw32-g++ (GCC) 6.4.0

You can also install MinGW-W64 stand-alone by downloading and run the installer.

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.