23

after searching about it i found some info (yet confusing for me)

Cygwin is a Unix-like environment and command-line interface for Microsoft Windows.

i found the above line in wikipedia but what does that mean? i'm not getting a clear idea about MinGW and cygwin and msys, please help

Paul R
  • 208,748
  • 37
  • 389
  • 560
Ario
  • 336
  • 2
  • 3
  • 11
  • With cygwin you can emulate in windows the linuk shell, so you can use command like `make` in windows ;-) – TheGr8_Nik Mar 28 '14 at 08:19
  • It does what it says on the tin: gives you a Unix-like environment on Windows. Instead of the usual DOS CMD window you get a bash shell and all the usual *nix tools. It's easy enough to install it and try it out - it works pretty well and does not disrupt your Windows environment. – Paul R Mar 28 '14 at 08:20
  • is it like if i have a source code for windows... then i can run it on linux if i compile it using cygwin? – Ario Mar 28 '14 at 08:21
  • 2
    @Ario, more like the opposite... if you have a linux source code, you can recompile it (with a fair degree of success) to run on windows – jsantander Mar 28 '14 at 08:23
  • whats the different between MinGW and Cygwin then? – Ario Mar 28 '14 at 08:27
  • 3
    MinGW is a port of some GNU development tools (primarily GCC) that runs on Windows. It compiles code which is written for Windows, to run on Windows. It does not allow you to compile POSIX specific code. – Benjamin Lindley Mar 28 '14 at 08:33

2 Answers2

22

Because it keeps confusing people:

  1. Cygwin: think of it as an OS. It provides a POSIX C runtime built on top of Windows so you can compile most Unix software to run on top of it. It comes with GCC, and to some extent, you can call the Win32 API from within Cygwin, although I'm not sure that is meant to happen or work at all.

  2. MSYS(2): a fork of Cygwin which has path translation magic to make native Windows programs work nicely with it. Its main goal is to provide a shell so you can run autotools configure scripts. You are not meant to build MSYS applications at all. Note that MSYS2 strives for much more and contains a full-blown package management system so you can easily install MinGW-w64 libraries and tools.

  3. MinGW(-w64): A native Windows port of the GCC compiler, including Win32 API headers and libs. It contains a tiny POSIX compatibility layer (through e.g. winpthreads, the unistd.h headers and some other bits), but you cannot compile POSIX software with this. This is best compared to MSVC, which also produces native code using the Win32 API.

Note that there are MinGW-w64 cross-compilers that run on Cygwin. With MSYS2, I frankly don't see a good reason to do that. Might as well run a VM with Linux if you're going to use Cygwin for that.

rubenvb
  • 74,642
  • 33
  • 187
  • 332
  • Would you say Cygwin is like terminal emulator or like a shell on the windows kernel or none of the above? – jfa Jun 30 '15 at 20:14
  • 1
    No, Cygwin is more like a GNU OS without the kernel, on top of Windows. MSYS(2) is more the shell-like thing. – rubenvb Jun 30 '15 at 20:17
  • What's the difference between an OS without the kernel and a shell if there's no GUI? – jfa Jul 01 '15 at 12:57
  • @JFA the userspace libraries and utilities. The shell is part of the latter. MSYS(2) misses most of the low-level libraries (which for GNU/Linux and Cygwin include a POSIX libc). As for the GUI, Cygwin is capable of running an X server, whereas that is not at all a goal or use for MSYS(2). – rubenvb Jul 01 '15 at 13:02
  • @rubenvbv `A native Windows port of the GCC compiler` what is meant by port ? I am not getting clearly. – Abhishek Mane Aug 20 '21 at 13:59
8

More or less from its web page

cygwin is

  1. a POSIX compatibility layer on top of windows API. This is mainly encapsulated in a cygwin1.dll
  2. a distribution system and repository of open source software compiled with this dll.

In a nutshell, if you have a linux source, you can try to recompile for cygwin and be able to run it on windows...

This enables to have accessible many of the typical unix commands (shells, gcc/g++, find....)

Alternatives are:

  • MSYS: are a set of typical unix command implemented in windows.
  • mingw: A gcc/g++ target able to produce win32 programs (note that cygwin gcc/g++ programs will have a dependency on cygwin1.dll that mingw programs will not have).
jsantander
  • 4,972
  • 16
  • 27