Difference Between Gnuwin32 and Cygwin

Difference between GNUWin32 and cygwin

Cygwin is a library that endeavours to make UNIX programs able to compile and run on Windows systems with minimal or no modifications, and a comprehensive set of packaged UNIX tools and applications compiled with this library. It is almost a complete wrapper around Windows. It includes an X server and an awful lot of the programs that you can expect to find in a Linux distribution. It is great for people who want to learn or use the UNIX command line in Windows.

MSYS is mostly a port of the UNIX tools necessary to build GNU style packages (with a configure etc) on Windows systems with the MinGW compiler. It uses a variant of the Cygwin library modified to sacrifice some compatibility for efficiency, and is more Windows-friendly.

GnuWin32 is simply a port of some of the GNU tools to Windows. Like MSYS, it uses msvcrt.dll, as well as an additional library to provide some UNIX compatibility functions. Its main purpose appears to be to allow Windows programs and batch files to use some of the GNU programs and libraries directly.

For the most part, they all provide UNIX programs on Windows, but there are many subtle differences, including:

  • Intent. Cygwin is for people who want to use UNIX on their Windows OS. MSYS is for people who want to build Windows programs using the GNU/UNIX build tools. GnuWin32 is a port of individual GNU programs and libraries to Windows.
  • Text files, particularly line endings. Cygwin lets you use CR/LF or LF. MSYS expects LF line endings. GnuWin32 programs expect CR/LF line endings.
  • Supplied programs. In particular, Cygwin has a lot more packages, and GnuWin32 doesn't provide any shells.

As for git, it is available with Cygwin - this version can be used in a Windows directory (accessible under /cygdrive). Also, as mentioned, there is msysgit.

GnuWin32 or Cygwin - from a programmers point of view

It is absolutely no contest

GnuWin32 does not include Bash

This is a critical part of the Cygwin distribution. Switching from cmd.exe to Bash was a huge boon to my productivity. cmd.exe is cripped in comparison to Bash.

GnuWin32 is old

Many program go years without being updated.

  • tar 2003
  • coreutils 2005
  • zlib 2005
  • make 2006
  • wget 2008

I would not use GnuWin32 unless I had no other choice.

What is the difference between Cygwin and MinGW?

As a simplification, it's like this:

  • Compile something in Cygwin and you are compiling it for Cygwin.

  • Compile something in MinGW and you are compiling it for Windows.

About Cygwin

Cygwin is a compatibility layer that makes it easy to port simple Unix-based applications to Windows, by emulating many of the basic interfaces that Unix-based operating systems provide, such as pipes, Unix-style file and directory access, and so on as documented by the POSIX standards. If you have existing source code that uses these interfaces, you may be able to compile it for use with Cygwin after making very few or even no changes, greatly simplifying the process of porting simple IO based Unix code for use on Windows.

When you distribute your software, the recipient will need to run it along with the Cygwin run-time environment (provided by the file cygwin1.dll). You may distribute this with your software, but your software will have to comply with its open source license. Even just linking your software with it, but distributing the dll separately, can still impose license restrictions on your code.

About MinGW

MinGW aims to simply be a port of GNU's development tools for Windows. It does not attempt to emulate or provide comprehensive compatibility with Unix, other that to provide a version of the GNU Compiler Collection, GNU Binutils and GNU Debugger that can be used natively in Windows. It also includes header files allowing the use of Windows' native API in your code.

As a result your application needs to specifically be programmed for Windows, using the Windows API, which may mean significant alteration if it was created to rely on being run in a standard Unix environment and use Unix-specific features. By default, code compiled in MinGW's GCC will compile to a native Windows X86 target, including .exe and .dll files, though you could also cross-compile with the right settings, since you are basically using the GNU compiler tools suite.

MinGW is a free and open source alternative to using the Microsoft Visual C++ compiler and its associated linking/make tools on Windows. It may be possible in some cases to use MinGW to compile something that was intended for compiling with Microsoft Visual C++ without too many modifications.

Even though MingW includes some header files and interface code allowing your code to interact with the Windows API, as with the regular standard libraries this doesn't impose licensing restrictions on software you have created.

Other considerations

For any non-trivial software application, such as one that uses a graphical interface, multimedia or accesses devices on the system, you leave the boundary of what Cygwin can do for you and further work will be needed to make your code cross-platform. But, this task can be simplified by using cross-platform toolkits or frameworks that allow coding once and having your code compile successfully for any platform. If you use such a framework from the start, you can not only reduce your headaches when it comes time to port to another platform but you can use the same graphical widgets - windows, menus and controls - across all platforms if you're writing a GUI app, and have them appear native to the user.

For instance, the open source Qt framework is a popular and comprehensive cross-platform development framework, allowing the building of graphical applications that work across operating systems including windows. There are other such frameworks too. In addition to the large frameworks there are thousands of more specialized software libraries in existence which support multiple platforms allowing you to worry less about writing different code for different platforms.

When you are developing cross-platform software from the start, you would not normally have any reason to use Cygwin. When compiled on Windows, you would usually aim to make your code able to be compiled with either MingW or Microsoft Visual C/C++, or both. When compiling on Linux/*nix, you'd most often compile it with the GNU compilers and tools directly.

Relationship between gcc, g++, cygwin, and wingw?

g++ and gcc are the gnu C++ and C compiler respectively. They're really the same compiler with different flags though.

MinGW is "Minimalist Gnu for Windows". It's a port of the gnu compiler to run on Windows.

Cygwin is another port of the gnu compiler (and various other utilities) to Windows. More accurately (IMO, anyway), it's leaving the compiler/programs running on POSIX, and porting a POSIX layer to run on Windows.

As to choosing between them: if you're running Linux, you probably want ot just get a package of gcc/g++ for the distro you're using.

If you're running Windows, it'll depend on your intent. Cygwin works well for porting existing Linux/POSIX code to Windows. If, however, you plan to write code, and just want a compiler, I'd go for MinGW instead.

One other note: the MinGW at MinGW.org hasn't been updated in years. If you decide to go with MinGW, I'd advise getting it from nuwen.net instead (it's updated quite regularly).

Difference between msysgit and Cygwin + git?

Edit 2018:

Since my 2010-2012-2014 answer, in 2015 Git for Windows uses msys2, as I detail here.

See more in "How are msys, msys2, and msysgit related to each other?".


Edit (2 more years later: October 2014)

Johannes Schindelin just explained (Oct. 2014) that msysgit is phased out:

We now have a light-weight Git for Windows SDK – which is essentially a standard MinGW/MSys system managed through the package manager mingw-get.

We decided to just phase out the name "msysGit" (as well as the GitHub org of the same name) and:

  • work on Git for Windows (with the corresponding GitHub org),
  • using the name "Git for Windows" for the installer aimed at "end-users" and
  • using the name "Git for Windows SDK" for the development environment targeting Git for Windows developers).

Update 2 years later: July 2012

Msysgit is here to stay, and unless you need to add a few hundreds of MB for cygwin, you really don't need Cygwin to just use Git on Windows.

And if you want to access GitHub, you get one package ("Git for Windows" + ssh keys registered for you on your GitHub account + a nice GUI) with GitHub for windows.

Both Git and msysgit are on GitHub.

The msysgit.github.com page clearly illustrates the difference between:

Git for Windows logo <----------> MsysGit logo

"Git for Windows": Pure users of Git | "MsysGit": for Testers, developers, custom installer maintainers

See also the msysgit FAQ:

What is this "MSys" thing in "MSysGit"?


MSys is an environment for Windows offering a Unix-type shell and a Perl interpreter. Because many parts of Git are still not builtins programmed in C, but instead shell and Perl scripts, Git for Windows needs such an environment.

Therefore we ship Git for Windows with a very minimal version of MSys.

MSys is also required to build Git, as we re-use the same Unix-type setup upstream Git uses. We ship a more complete MSys environment, including GCC, as build environment (which is therefore nick-named ''msysGit'').

We compile Git as a pure MinGW program, though, i.e. a program without any link-dependencies on anything but standard Windows libraries.

So unless you need to use any parts of Git that are still implemented only as shell or Perl scripts, you can get away with running plain git.exe.


Original answer: June 2010

a/ You can resize and copy-paste in Git bash, like in any other Windows Shell.

b/ You are probably using "Git for windows", and not msysgit. From the wiki:

  • msysGit is the development environment to compile Git for Windows. It is complete, in the sense that you just need to install msysGit, and then you can build Git. Without installing any 3rd-party software.
  • Git for Windows is an installer which installs Git -- and only Git.

It is easy to see the difference:

  • the installers for Git have the prefix Git-,
  • the msysGit installers have the prefix msysGit-.

Another telltale is that the msysGit installers come in two flavors: fullinstall and netinstall.

Further, msysGit does not install to C:\Program Files by default.

But msysGit comes with gcc, the GNU C Compiler.

c/ From MSysGitHerald10:

Remember:

  • MinGW is really a very thin compile-time layer over the Microsoft Runtime; MinGW programs are therefore real Windows programs, with no concept of Unix-style paths or POSIX niceties such as a fork() call.
  • MSys, in contrast, is a slimmed-down version of Cygwin (an old version at that), whose only purpose is to provide enough of a POSIX layer to run a bash.

And that is not always welcomed:

When working on Windows, I dislike that msysGit, as the name suggests, depends on MSYS and on tools from the Unix world. I believe all programs in the Git distribution should become binaries compiled for a specific platform, and not rely on shell interpreters or third-party languages like Tcl/Tk.

Even though, it is far better than the first Git on Cygwin installations from 2007.

Differences between MSYS2 and Cygwin

Traditionally MSYS bash has been inferior, but mostly because Cygwin remained under active development whereas MSYS didn't. MSYS forked from Cygwin version 1.3.3 and never re-synced, whereas MSYS2 resyncs with the Cygwin project regularly.

We don't have a "sweet pacman like package manager", we have as direct a re-compilation of Arch Linux's pacman package manager as we could achieve.

MSYS2 doesn't have cygwin.dll but it does have msys-2.0.dll which does the same thing (and some more besides). Specifically, arguments that look like paths and the PATH env. var are converted to Windows form when running Windows-native software.

As for whether it's slower, I expect there'd be very little difference but MSYS2 would be a tiny amount slower due to the extra conversion work. Then again, chances are you'll run more Windows-native software from within MSYS2 (such as MinGW-w64 compilers) than you would from Cygwin so that'll shift things back in MSYS2's favour.

Difference between Cygwin and Command prompt when running an c++ application through command line

Terminals in Windows like CMD and PowerShell launch applications in non-blocking mode (usually called the headless mode, if I'm not wrong. And it holds good for all executable files). There's nothing to bother until your application is running fine.

Cygwin, on the contrary, provides a Linux-like functionality, and thus follows the blocking nature of launching the application. That results in the Cygwin terminal to wait for the running application to quit to continue working.

Linux or Windows version of a library in Cygwin?

In Cygwin, you install Boost libraries as per Unix/Linux. From the documentation

Getting Started on Windows

A note to Cygwin and MinGW users

If you plan to use your tools from the Windows command prompt, you're in the right place.
If you plan to build from the Cygwin bash shell, you're actually running on a POSIX
platform and should follow the instructions for getting started on Unix variants.
Other command shells, such as MinGW's MSYS, are not supported—they may or may not work.



Related Topics



Leave a reply



Submit