What is the difference between Cygwin and MinGW?

http://stackoverflow.com/questions/771756/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

The purpose of Cygwin is to make porting *nix-based applications to Windows much easier, by emulating many of the small details that Unix-based operating systems provide, and are documented by the POSIX standards. If your application assumes that it can use Unix feature such as pipes, Unix-style file and directory access, and so forth, then you can compile it in Cygwin and Cygwin itself will act as a compatibility layer around your application, so that many of these Unix-specific paradigms can continue to be used with little or no modification to your application.

If you want to compile something for Cygwin and distribute that resulting application, you must also distribute the Cygwin run-time environment (provided by cygwin1.dll) along with it, and this has implications for what types of software license you may use.

About MinGW

MinGW is a Windows port of the GNU compiler tools, such as GCC, Make, Bash, and so on. It does not attempt to emulate or provide comprehensive compatibility with Unix, but instead it provides the minimum necessary environment to use GCC (the GNU compiler) and a small number of other tools on Windows. It does not have a Unix emulation layer like Cygwin, but as a result your application needs to specifically be programmed to be able to run in Windows, which may mean significant alteration if it was created to rely on being run in a standard Unix environment and uses Unix-specific features such as those mentioned earlier. 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. MinGW is an open-source alternative to Microsoft Visual C++ compiler and its associated linking/make tools.

Considerably sophisticated cross-platform frameworks exist which make the task of porting applications to various operating systems easily - for example the Qt framework is a popular framework for cross-platform applications. 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.

Wikipedia does a comparison here.

From Cygwin‘s website:

  • Cygwin is a 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.

From Mingw‘s website:

MinGW ("Minimalistic GNU for Windows") is a collection of freely available and freely distributable Windows specific header files and import libraries combined with GNU toolsets that allow one to produce native Windows programs that do not rely on any 3rd-party C runtime DLLs.  

    

Read these answered questions to understand the difference between Cygwin and MinGW.



Question #1: I want to create an application that I write source code once, compile it once and run it in any platforms (e.g. Windows, Linux and Mac OS X…).

Answer #1: Write your source code in JAVA. Compile the source code once and run it anywhere.



Question #2: I want to create an application that I write source code once but there is no problem that I compile the source code for any platforms separately (e.g. Windows, Linux and Mac OS X …).

Answer #2: Write your source code in C or C++. Use standard header files only. Use a suitable compiler for any platform (e.g. Visual Studio for Windows, GCC for Linux and XCode for Mac). Note that you should not use any advanced programming features to compile your source code in all platforms successfully. If you use none C or C++ standard classes or functions, your source code does not compile in other platforms.



Question #3: In answer of question #2, it is difficult using different compiler for each platform, is there any cross platform compiler?

Answer #3: Yes, Use GCC compiler. It is a cross platform compiler. To compile your source code in Windows use MinGW that provides GCC compiler for Windows and compiles your source code to native Windows program. Do not use any advanced programming features (like Windows API) to compile your source code in all platforms successfully. If you use Windows API functions, your source code does not compile in other platforms.



Question #4: C or C++ standard header files do not provide any advanced programming features like multi-threading. What can I do?

Answer #4: You should use POSIX (Portable Operating System Interface [for UNIX]) standard. It provides many advanced programming features and tools. Many operating systems fully or partly POSIX compatible (like Mac OS X, Solaris, BSD/OS and ...). Some operating systems while not officially certified as POSIX compatible, conform in large part (like Linux, FreeBSD, OpenSolaris and ...). Cygwin provides a largely POSIX-compliant development and run-time environment for Microsoft Windows.



Thus:

To use advantage of GCC cross platform compiler in Windows, use MinGW.

To use advantage of POSIX standard advanced programming features and tools in Windows, use Cygwin.

时间: 2024-08-03 23:19:02

What is the difference between Cygwin and MinGW?的相关文章

Cygwin 与 MinGW/MSYS/MSYS2,如何选择?

本文链接:http://zengrong.net/post/1557.htm 什么是Cygwin和MinGW?请看这篇:Msys/MinGW与Cygwin/gcc. 在无法完全转换到Linux系统的前提下,我一直在 Cygwin 下工作,使用全套的Linux移植工具,学习Bash编程. 但Cygwin由于工作在模拟模式下,速度较慢,相比而言, MinGW 就要快不少. 下面是我选择的对比: 特点 Cygwin MinGW/MSYS MSYS2 是否GNU 否 是 是 更多软件支持? 支持绝大多数

[cross compile]cygwin和mingw

Unix下编译通过的C代码,在win32下编译是不能通过的 ,当然Unix 和win32的API都是符合标准C,也就是说,大多数函数调用在unix和win32下是相同的.但是,unix有自己一些独特的API(如fork,spawn,signals,select,sockets等),如果代码中使用了这些API,在win32下当然找不到对应的库.    但是,这些API的功能在win32中也能实现,也许你已经发现了一个能让window编译Unix风格代码的方法:    1.修改编译器,让window

cygwin和mingw的区别

之前由于做一些JNI的开发,安装了MinGW,最近有个项目需要用到cygwin,于是就有个疑问,这两个东西有什么区别?在网上看了些资料,在这里复制粘贴一下,以备后查. Unix下编译通过的C代码,在win32下编译是不能通过的 ,当然Unix 和win32的API都是符合标准C,也就是说,大多数函数调用在unix和win32下是相同的.但是,unix有自己一些独特的API(如fork,spawn,signals,select,sockets等),如果代码中使用了这些API,在win32下当然找不

Cygwin与minGW

这几天关注了一下它们, 其实我是不想安装一下vs来编写一些小东西. 本来想写个小exe,于是跑到vs的bin下面把cl与link搞出来,却发现cl还要配置什么的,也不太清楚直接就二个exe与部分dll能否使用.折腾二下, link可以使用,cl却不能使用.也没见谁这么弄过,于是放弃了. 再找window编译win32 c时,发现有gcc,找到minGW,与Cygwin,折腾比较了好大一会,才发现. mingGW最大区别就是把那些bin编译成cmd下可以独立运行的, 而Cygwin,基本上是cmd

MinGW and Cygwin – An Introduction and Differences

If you are using Linux and your are a big fan of shell and its other utilities like grep, ls, make and its compilers gcc and g++, and if you want these utils on Windows platform, then this articles is for you. Even if you are not a developer, but sti

mingw和cygwin区别

minGW与cygwin ========================== 首先MingW和cygwin都可以用来跨平台开发. MinGW是Minimalistic GNU for Windows的缩写,也就是Win版的 精简的GCC . MinGW 收集了一系列免费的Windows 使用的头文件和库文件:同时整合了GNU( http://www.gnu.org/ )的工具集,特别是GNU 程序开发工具,如经典gcc, g++, make等. Microsoft的有一套unix的子系统的开发

C/C++ 跨平台交叉编译、静态库/动态库编译、MinGW、Cygwin、CodeBlocks使用原理及链接参数选项

目录 0. 引言 1. 交叉编译 2. Cygwin简介 3. 静态库编译及使用 4. 动态库编译及使用 5. MinGW简介 6. CodeBlocks简介 0. 引言 UNIX是一个注册商标,是要满足一大堆条件并且支付可观费用才能够被授权使用的一个操作系统.linux是unix的克隆版本,是由其创始人Linus和诸多世界知名的黑客手工打造的一个操作系统.为什么linux和unix之间有很多软件可以很轻松的移植?因为linux也满足POSIX规范,所以在运行机制上跟unix相近.同时,POSI

[Android]Cygwin使用及NDK编译方法

在Windows XP, Cygwin, NDK SDK r5b下成功编译了ffmpeg,下面是完整的编译过程: 一.准备工作 2.下载Cygwin, 请猛击这里 3.下载Android SDK,请猛击这里,Android SDK的网页 4.下载Android NDK SDK r5b, 请猛击这里,NDK SDK的网页 5.下载ffmpeg,可以下载压缩包,也可以git一个snapshot 好了,有必要说明一下Android SDK和Android NDK SDK的区别: Android SDK

在WINDOWS上通过VAGRANT练习ANSIBLE

有点曲折,但没办法,还要通过VAGRANT里的ANSIBLE建DOCKER呢.. VagrantFile # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure(2) do |config| config.vm.box = "ubuntu/trusty64" if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil config.vm.synced_