I'm wondering in what situations one uses Cygwin to compile C code and when one would opt for MinGW. I came over What is the difference between Cygwin and MinGW? describing the differences between Cygwin and MinGW.
As far as I understood, one could say the following:
However, my understanding seems to be wrong, because I was able to compile a dummy program that included pthread.h with MinGW. What did I understand wrongly?
It doesn't have anywhere near all the features of Cygwin, but is ideal for programmers wanting to use MinGW. MinGW is higher performance than Cygwin, but it's also 32-bit which may be a problem with your applications. There is a 64-bit environment similar to MinGW but it's a different project.
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 ".
In MinGW, you can write native windows programs (by calling the native Win32 C interface), but you cannot compile everything uses POSIX functionality not present in windows. The most evident case is the missing of the standard <thread> interface of MinGW and a limited <locale> support.
Cygwin offers users a Linux-like experience in a Windows environment. This capability helps developers migrate applications from Unix or Linux to Windows-based systems and makes it easier to support their applications running on the Windows platform. At the heart of the Cygwin collection of tools is the cygwin1.
Your understanding is essentially correct. However, there's a win32 pthreads port, which is a thin wrapper over the native threads API.
A more appropriate example would be fork()
, which cannot be emulated easily on win32. To do so, Cygwin enforces a fixed DLL memory layout, and things will explode if a library can't be loaded where it's supposed to go (cue rebaseall
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With