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一样。
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
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