关于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 ...
随机推荐
- Effective C++笔记(三):资源管理
参考:http://www.cnblogs.com/ronny/p/3745098.html 资源:动态分配的内存.文件描述器.互斥锁.图形界面中的字型与笔刷.数据库连接以及网络sockets等, ...
- beego学习笔记(2)
BEEGO的几个特点: 简单化 RESTful 支持.MVC 模型,可以使用 bee 工具快速地开发应用,包括监控代码修改进行热编译.自动化测试代码以及自动化打包部署. 智能化 支持智能路由.智能监控 ...
- MySQL-事务特性
1. 事务概念引入: 现实生活中,我们往往经常会进行转账操作,转账操作可以分为两部分来完成,转入和转出.只有这两部分都完成了才可以认为是转账成功.在数据库中,这个过程是使用两条语句来完成的,如果其中任 ...
- Mariadb 10.2中的json使用及应用场景思考
-- 创建示例表DROP TABLE IF EXISTS `t_base_user`;CREATE TABLE `t_base_user` ( `USER_ID` char(36) CHARACT ...
- int类中的方法
我们知道在python中,一切对象都是类,对象的方法都封装在类中,现在来探讨一下int类中的方法: 我们可以通过help(int)和dir(int)来查看int类中都封装了那些方法: 1.bi ...
- Asp.net MVC CSS/Javascript Bundle 配置文件
Asp.net mvc 中使用 Web Optimization 可以合并.压缩JS和CSS文件,但是每次修改都要改代码 ~/App_Start/BundleConfig.cs ,遂有了将它挪到配置文 ...
- 开源IDS系列--解决barnyard2 停止运行 libmysqlclient.so.16.0.0
现象: barnyard2运行一段时间后,会自行停止,未在/var/log/barnyard2或/var/log/suricata中发现相关日志. 排查: 在/var/log/message中存在以下 ...
- Mysql Federated Server 示例
Federated存储引擎访问在远程数据库的表中的数据,而不是本地的表.创建一个Federated表的时候,服务器在数据库目录创建一个表定义文件.无其它表被创建,因为实际的数据在一个远程数据库上.这不 ...
- Mybatis使用入门
一.Mybatis简介 1.传统JDBC的不足 我们首先看一下JDBC的一般操作流程.比如,我想从user表中获取根据name获取数据,下面是传统JDBC代码: package lkb.webchat ...
- Mybatis源码分析之参数处理
Mybatis对参数的处理是值得推敲的,不然在使用的过程中对发生的一系列错误直接懵逼了. 以前遇到参数绑定相关的错误我就是直接给加@param注解,也稀里糊涂地解决了,但是后来遇到了一些问题推翻了我的 ...