关于GCC Cygwin MinGW MSYS
[转载]关于Gcc/MinGW/Cygwin/Msys
http://blog.sciencenet.cn/blog-778757-616920.html
一、GCC的历史
GCC是一个原本用于Unix-like系统下编程的编译器。
不过,现在GCC也有了许多Win32下的移植版本。
所以,也许对于许多Windows开发者来说,GCC还是一个比较陌生的东西。
所以,我希望通过这章的叙述,让你——一个Windows开发者对GCC这一个优秀的编译器有一个大概的了解。
GCC是GNU公社的一个项目。
是一个用于编程开发的自由编译器。
最初,GCC只是一个C语言编译器,他是GNU C Compiler 的英文缩写。
随着众多自由开发者的加入和GCC自身的发展,如今的GCC以经是一个包含众多语言的编译器了。
其中包括 C,C++,Ada,Object C和Java等。所以,GCC也由原来的GNU C Compiler变为GNU Compiler Collection。
也就是 GNU编译器家族 的意思。当然,如今的GCC借助于他的特性,具有了交叉编译器的功能,即在一个平台下编译另一个平台的代码。
直到现在,GCC的历史仍然在继续,他的传奇仍然被人所传颂。
二、Windows下的GCC家族
起初,GCC是用于Unix,Unix-like系统的编译器。
不过,现在Windows下也出现了GCC的稳定移植版。
这要感谢Internet上众多程序员的共同努力。
如今,在Windows下比较流行的GCC移植版主要有三个。他们是 MinGW,Cygwin和Djgpp。
虽然,Djgpp是应用于DOS系统的,考虑到windows对DOS的兼容,所以也将Djgpp纳入其中了。
总体来说,MinGW,Cygwin和Djgpp各有特色,针对不同的应用场合,可以选择不同的移植版来满足需要。
MinGW 的主要方向是让GCC的Windows移植版能使用Win32API来编程。
Cygwin 的目标是能让Unix-like下的程序代码在Windows下直接被编译。
Djgpp 则是想让DOS下也能用上GCC。
所以,对于开发人员不同的需求。选择合适的移植版会让工作变得轻松而高效。
三、分别介绍
MinGW
Minimalistic GNU for Windows。
她是一个建立在GCC和binutils 项目上的编译器系统。和其他GCC的移植版相比,她可以说是最接近Win32的一个了。
因为,MinGW几乎支持所有的Win32API,这也是MinGW的特色之一。
她所连接的程序,不需要任何第三方库就可以运行了。
在某种程度上看,MinGW更像是VC的替代品。
官网: http://www.mingw.org
Cygwin
其实并不是一个GCC。她是让Windows拥有Unix-like环境的软件。
所以,GCC自然也就会包含在里面。
不过,对于开发者,Cygwin是一个开发环境。而对于用户来说Cygwin是一个运行环境。
Cygwin唯一和MinGW最大的区别在于,使用Cygwin可以在Windows下调用Unix-like的系统函数。
比如进程函数,等等。所以,虽然说,Cygwin是运行在Windows下的,但是她还是使用的是Unix-like系统的函数和思想。
官网: http://www.cygwin.com/
MSYS
Unix-like command line utilities
包括基本的bash, make, gawk and grep 等等。通常也可以认为是小型的UNIX on Windows。提供在windows上模拟Unix环境来使用MinGW。
msys-cn :http://code.google.com/p/msys-cn/MSYS
中国发行版,用UNIX开发环境开发Windows程序。
MSYS在windows下模拟了一个类unix的终端,它只提供了MinGW的用户载入环境,在MSYS模拟的unix环境下使用MinGW,就像在Unix使用gcc一样。
What is the difference between Cygwin and MinGW?
Cygwin is an attempt to create a complete UNIX/POSIX environment on Windows. To do this it uses various DLLs. While these DLLs are covered by GPLv3+, their license contains an exception that does not force a derived work to be covered by the GPLv3+. MinGW is a C/C++ compiler suite which allows you to create Windows executables without dependency on such DLLs - you only need the normal MSVC runtimes, which are part of any normal Microsoft Windows installation.
You can also get a small UNIX/POSIX like environment, compiled with MinGW called MSYS. It doesn't have anywhere near all the features of Cygwin, but is ideal for programmers wanting to use 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 POSIXstandards. 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 acompatibility 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
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.
http://zhidao.baidu.com/question/351787500.html GCC 原名为 GNU C 语言编译器,因为它原本只能处理 C语言。GCC 很快地扩展,变得可处理 C++。之后也变得可处理 Fortran、Pascal、Objective-C、Java, 以及 Ada与其他语言。
GDB是GNU开源组织发布的一个强大的UNIX下的程序调试工具。
MinGW,即 Minimalist GNU For Windows。它是一些头文件和端口库的集合,该集合允许人们在没有第三方动态链接库的情况下使用 GCC 产生 Windows32 程序。
cygwin是一个在windows平台上运行的unix模拟环境,是cygnus solutions公司开发的自由软件(该公司开发了很多好东西,著名的还有eCos,不过现已被Redhat收购)。它对于学习unix/linux操作环境,或者从unix到windows的应用程序移植,或者进行某些特殊的开发工作,尤其是使用gnu工具集在windows上进行嵌入式系统开发,非常有用。随着嵌入式系统开发在国内日渐流行,越来越多的开发者对cygwin产生了兴趣。
http://www.cnblogs.com/itech/archive/2010/04/08/1707702.html
2,MSYS实际上为mingw提供了一个shell界面,在这个界面中能够调用mingw的gcc,g++编译器命令,还提供了一些ls,cd,grep等等基本的命令。而且主要的是还能够使用./configure命令来配置软件,这个用途可能就是MSYS的最开始的初衷吧。
3,与mingw/MSYS主要用来提供编译环境不同,cygwin更像是一个运行在windows上的linux系统,各种命令,各种服务很多很全,而且,与mingw一样的,也可以用cygwin来编译linux系统中的程序,使之能在windows上运行,与mingw不同的之处就是,用cygwin编译出来的程序,在windows上运行的时候需要cygwin.dll运行库的支持,而mingw则是生成出来的二进制文件可以直接运行,不需要依赖动态链接库。
MinGW,即 Minimalist GNU For Windows。它是一些头文件和端口库的集合,该集合允许人们在没有第三方动态链接库的情况下使用 GCC(GNU Compiler C)产生 Windows32 程序。
MSYS:Minimal GNU(POSIX)system on Windows,是一个小型的GNU环境,包括基本的bash,make等等。是Windows下最优秀的GNU环境。
cygwin是一个在windows平台上运行的unix模拟环境,是cygnus solutions公司开发的自由软件。
基本上Cygwin是提供了在windows上使用unix环境的套件不过开发程式的话编译出来的程式码是需要在Cygwin下才能正确执行虽然也是可以使用-mno-cygwin的flag
MSYS & MinGW都包括了許多的子套件在里面首先MSYS是Minimal SYStem的缩写提供了类似Bourne shell环境下要编译程式的一些utility MSYS & MinGW都包括了许多的子套件在里头首先MSYS是Minimal SYStem的缩写提供了类似Bourne shell环境下要编译程式的一些utility像automake之类。
而MinGW則是Minimalistic GNU for Windows的缩写他包含了许多的compiler for windows、win32api等等是用來编译for windows的执行档用不像Cygwin编出來的程式必須在Cygwin下才能跑而MinGW则是Minimalistic GNU for Windows的缩写他包含了许多的compiler for windows、win32api等等是用来编译for windows的执行档用不像Cygwin编出来的程式必须在Cygwin下才能跑
因此可以看出因此可以看出Cygwin & MSYS的角色是有重叠的我們可以在Cygwin提供的环境下用MinGW的compiler&library来编出可单独执行的Windows 执行档在MinGW的FAQ也有提到这点就是把PATH设定正确,在Cygwin下使用MinGW的compiler & library即可 。
关于GCC Cygwin MinGW MSYS的更多相关文章
- Cygwin, MinGW/MSYS, MinGW-W64/MSYS2
1. Cygwin http://www.cygwin.com/ Cygwin is a large collection of GNU and Open Source tools which pro ...
- Cygwin 与 MinGW/MSYS/MSYS2,如何选择?甚至还有GNU utilities for Win32
Cygwin与MinGW/MSYS,如何选择? 2012-11-03更新:加入 MSYS 的内容. 2013-10-15更新:修改表格格式,加入介绍链接. 2014-12-17更新:加入 MSYS2 ...
- Windows 下使用 mingw+msys 交叉编译 Android Unity Mono
对于没有升级到 Unity5.4的用户,发布安卓版本都会有对 C# 脚本进行加密的需求,我们项目在裸奔了很长时间后,决定开始做这件事. 网上查看了很多资料,我很希望直接在 windows 下编译而不去 ...
- MSYS是一个小型的GNU环境,包括基本的bash,make等等,与Cygwin大致相当(双击“D:\MinGW\msys\1.0\msys.bat”,启动MinGW终端)
1 简介 MinGW,是Minimalist GNUfor Windows的缩写.它是一个可自由使用和自由发布的Windows特定头文件和使用GNU工具集导入库的集合,允许你在GNU/Linux和 ...
- gcc和MinGW的异同(在cygwin/gcc做的东西可以无缝的用在linux下,没有任何问题,是在windows下开发linux程序的一个很好的选择)
cygwin/gcc和MinGW都是gcc在windows下的编译环境,但是它们有什么区别,在实际工作中如何选择这两种编译器. cygwin/gcc完全可以和在linux下的gcc化做等号,这个可以从 ...
- 开源项目:windows下使用MinGW+msys编译ffmpeg
本文参考了网络上的不少文章,但由于版本环境的问题参考文章并不能直接指导编译,本文吸收多方经验,并在自己多次编译实验的基础上写成,欢迎转载,请注名出处. FFmpeg是在Linux平台下开发的,但 ...
- windows 下使用 MinGW + msys 编译 ffmpeg
本文参考了网络上的不少文章,但由于版本环境的问题参考文章并不能直接指导编译,本文吸收多方经验,并在自己多次编译实验的基础上写成,欢迎转载,请注名出处. FFmpeg是在Linux平台下开发的,但 ...
- gcc和MinGW的异同
cygwin/gcc和MinGW都是gcc在windows下的编译环境,但是它们有什么区别,在实际工作中如何选择这两种编译器. cygwin/gcc完全可以和在linux下的gcc化做等号,这个可以从 ...
- windows 7下mingw+msys编译ffmpeg
windows 7下mingw+msys编译ffmpeg 1-->下载安装MingW,mingw-get-inst-20120426.exe http://sourceforge.ne ...
随机推荐
- spring-mybatis.xml配置
1.自动扫描 <context:component-scan base-package="com.javen" /> 2.引入配置文件 <bean id=&quo ...
- 报错:Cobbler check 时报错
报错:[root@test88 ~]# cobbler checkTraceback (most recent call last): File "/usr/bin/cobbler&quo ...
- python多线程下载文件
从文件中读取图片url和名称,将url中的文件下载下来.文件中每一行包含一个url和文件名,用制表符隔开. 1.使用requests请求url并下载文件 def download(img_url, i ...
- python爬取漫画
抓取漫画的网址是:sf互动传媒 抓取漫画的由来也是看了知乎上有人说用爬取漫画,然后自己也玩玩 首页中每个漫画的url是类似这样存储的: <tr> <td height="3 ...
- 洛谷P1615 西游记公司 题解
题目传送门 这道题题面写得非常好. 但好像并没有什么ruan用. 这道题貌似就是把时间差求出来,乘上猪八戒能偷的电脑数就好了.(注意long long) #include<bits/stdc++ ...
- OPENSSL问题,使用fsockopen()函数提示错误
环境配置 系统环境 CentOS7.2WDCP v3.2.2 lanmp PHP 多版本 指定使用5.6 OpenSSL 1.0.2h 3 May 2016 php.ini相关设置allow_url ...
- beego离线安装及运行
官网: https://beego.me/ 由于公司上不了网,啥都得下载到本地来弄. go的安装不多说了,GOPATH要设置好的. 先离线下载好https://github.com/astaxie/b ...
- day4 装饰器深入解析
Python装饰器 装饰器是在不修改源码给代码添加功能的常用方法.@是装饰的标志.我们知道,在给代码增加功能的时候,要遵循开放封闭的原则,不能随便更改原码,因此装饰器的功能就显示出来了,只需要在函数前 ...
- bzoj 1108
思路:水题, 将所有点按x轴对称反转,就变成了两堆点的坐标和的差.. #include<bits/stdc++.h> #define LL long long #define fi fir ...
- 454. 四数相加 II
给定四个包含整数的数组列表 A , B , C , D ,计算有多少个元组 (i, j, k, l) ,使得 A[i] + B[j] + C[k] + D[l] = 0. 为了使问题简单化,所有的 A ...