> For the complete documentation index, see [llms.txt](https://kmanu225.gitbook.io/cs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kmanu225.gitbook.io/cs/software-engineering/unix-linux-on-windows-choosing-the-right-environment/cygwin-posix-compatibility-on-windows.md).

# Cygwin: POSIX Compatibility on Windows

**Cygwin** provides a POSIX compatibility layer on Windows. Its main use case is very specific:

> You already have source code written for Linux or another POSIX system, but you need to build and run that software on Windows.

For example, the code may assume APIs and behavior such as:

```
fork()
signals
POSIX permissions
Unix-style paths
pipes
pseudo-terminals
```

Those interfaces either do not exist on Windows or behave very differently.

Without Cygwin, porting the application may require replacing large parts of the POSIX-specific code with Windows APIs.

With Cygwin, you can often keep much of the original source code and rebuild it against the Cygwin runtime:

```
POSIX/Linux source code
        |
        v
Compile with Cygwin
        |
        v
Windows executable
        |
        +-- uses cygwin1.dll
```

The application then runs on Windows, while `cygwin1.dll` provides much of the POSIX behavior the source code expects.

That is the core reason to use Cygwin: **you are not trying to run an existing Linux binary; you are recompiling POSIX-oriented source code so that it can run on Windows with minimal porting effort.**

## How it works

Cygwin also provides familiar tools such as:

```bash
bash
grep
sed
awk
make
gcc
ssh
```

But these are not Linux programs running on a Linux kernel. They are Windows executables built for the Cygwin environment.

## Cygwin vs [MinGW](/cs/software-engineering/unix-linux-on-windows-choosing-the-right-environment/mingw-w64-gnu-tools-on-windows.md)/[MSYS2](/cs/software-engineering/unix-linux-on-windows-choosing-the-right-environment/msys2-a-unix-like-development-environment-for-windows.md)

The key difference is:

```
MinGW-w64 / MSYS2
    -> adapt the application to native Windows APIs
    -> native Windows application

Cygwin
    -> preserve more POSIX assumptions
    -> application uses the Cygwin compatibility layer
```

Use **MinGW/MSYS2** when Windows is the real platform you want to target natively.

Use **Cygwin** when you already have Unix/POSIX-oriented source code and want to make it run on Windows without rewriting large parts of it.

## What Cygwin is not

Cygwin is not Linux. It cannot directly run normal Linux ELF binaries, and it does not provide a Linux kernel. Its strength is **porting and rebuilding POSIX software for Windows**.

With [**WSL**](https://learn.microsoft.com/en-us/windows/wsl/) **instead**, the approach changes completely: instead of adapting the application to Windows, you run it inside a real Linux environment.
