MinGW和MSYS简介

来源:互联网 发布:jenkins python 自动化 编辑:程序博客网 时间:2024/05/21 14:17

MinGW 和 MSYS

分类: linux开发 4162人阅读 评论(1)收藏举报

 今天在编译一个开源软件时,用到了MinGW 和MSYS。在这里介绍下他们的功能和配置。

MinGW是指只用自由软件来生成纯粹的Win32可执行文件的编译环境,它是Minimalist GNU on Windows的略称。详情请参考<http://www.mingw.org>。

这里的“纯粹”是指「使用msvcrt.dll的应用程序」。无法使用MFC (Microsoft Foundation Classes)。

MinGW:一个可自由使用和自由发布的Windows特定头文件和使用GNU工具集导入库的集合,允许你生成本地的Windows程序而不需要第三方C运行时库。

MinGW,即 Minimalist GNU For Windows。它是一些头文件和端口库的集合,该集合允许人们在没有第三方动态链接库的情况下使用 GCC(GNU Compiler C)产生 Windows32 程序。  
在基本层,MinGW 是一组包含文件和端口库,其功能是允许控制台模式的程序使用微软的标准C运行时间库(MSVCRT.DLL),该库在所有的 NT OS 上有效,在所有的 Windows 95 发行版以上的 Windows OS 有效,使用基本运行时间,你可以使用 GCC 写控制台模式的符合美国标准化组织(ANSI)程序,可以使用微软提供的 C 运行时间扩展。该功能是 Windows32 API 不具备的。下一个组成部分是 w32api 包,它是一组可以使用 Windows32 API 的包含文件和端口库。与基本运行时间相结合,就可以有充分的权利既使用 CRT(C Runtime)又使用 Windows32 API 功能。  

MinGW 官方网站为 http://www.mingw.org
实际上 MinGW 并不是一个 C/C++ 编译器,而是一套 GNU 工具集合。除开 GCC (GNU 编译器集合) 以外,MinGW 还包含有一些其他的 GNU 程序开发工具 (比如 gawk bison 等等)。
开发 MinGW 是为了那些不喜欢工作在 Linux(FreeBSD) 操作系统而留在 Windows 的人(比如我)提供一套符合 GNU 的 GNU 工作环境。
(此前的 cygwin 虽然也是 GNU 的 Windows 移植,但是 cygwin 是有版权的,而不是 GNU。)
所以,使用 MinGW 我们就可以像在 Linux 下一样使用 GNU 程序开发工具。

GCC 就是 MinGW 的核心所在,GCC 是一套支持众多计算机程序语言的编译系统,而且在语言标准的实现上是最接近于标准的。并且 GCC 几乎可以移植到目前所有可用的计算机平台。(我的电脑上就还装有 DevKitPro,里面包含 GCC 的 ARM(for GBA/DS/GP32) 和 MIPS(for PSP) 版本。)
GCC 本身不像 VC 那样拥有 IDE 界面(在 Windows 上也存在 Dev C++ 之类的支持 MinGW 编译器的 IDE)。源代码编辑你可以选用任何你喜欢的文本编辑器(据说微软的开发人员包括 VC 的开发都不用 VC 所带的 IDE 编辑器,而是选用 GNU 的 VIM 编辑器)。然后使用 make 等工具来进行软件项目的编译、链接、打包乃至发布。而像 cvs(svn) 源代码版本控制工具可以让世界上任何一个角落的人都可以参与到软件项目中来。

关于 MFC,微软基础库类,这个随 VC++ 携带的一个源代码公开的开发包,和其他 Windows 程序开发包是一样的。如果有 VC++ 的授权,你完全可以使用 MFC 的源代码,也就是你使用 GCC 来编译 MFC 程序是完全可以的。
当然,GNU 下也很多 Windows 程序开发包,甚至有一些是支持跨平台使用的。不仅仅可以直接把源代码编译为 Windows 程序,也可以不经修改编译为其他操作系统的图形程序。
不过 GNU 下,最流行的图形界面开发库是 GTK+。GTK+ 也能很好的运行在 Windows 平台(比如 GIMP 和 Gaim)。
总体说来,使用 MinGW 就是 GNU。
MSYS:Minimal GNU(POSIX)system on Windows,是一个小型的GNU环境,包括基本的bash,make等等。是Windows下最优秀的GNU环境。(是否厌倦了Cygwin蜗牛般的shell环境,试试MSYS中的rxvt吧)

安装

使用MinGW:http://prdownloads.sourceforge.net/mingw/MinGW-5.0.3.exe?download

下载后安装,选择缺省选项(Current),选择g++,然后MinGW会自动下载相关的软件,期间可能需要不少时间(老外的网站)。

下载http://prdownloads.sourceforge.net/mingw/MSYS-1.0.10.exe?download

下载后安装,中间会问你MinGW安装在哪里,按照安装提示输入即可。

安装好后,设置windows的环境变量PATH,加上c:/MinGW/bin,然后运行菜单MinGW/MSYS/msys

 

Welcome to MinGW.org

Home of the MinGW, MSYS and mingwPORT Projects


MinGW, a contraction of "Minimalist GNU for Windows", is a minimalist development environment for native Microsoft Windows applications.

MinGW provides a complete Open Source programming tool set which is suitable for the development of native MS-Windows applications, and which do not depend on any 3rd-party C-Runtime DLLs. (Itdoes depend on a number of DLLs provided by Microsoft themselves, as components of the operating system; most notable among these is MSVCRT.DLL, the Microsoft C runtime library. Additionally, threaded applicationsmust ship with a freely distributable thread support DLL, provided as part of MinGW itself).

MinGW compilers provide access to the functionality of the Microsoft C runtime and some language-specific runtimes.MinGW, being Minimalist, does not, and never will, attempt to provide a POSIX runtime environment for POSIX application deployment on MS-Windows. If you want POSIX application deployment on this platform, please considerCygwin instead.

Primarily intended for use by developers working on the native MS-Windows platform, but also available for cross-hosted use, (see note below -- you may need to follow the "read more" link to see it),MinGW includes:

  • A port of the GNU Compiler Collection (GCC), including C, C++, ADA and Fortran compilers;
  • GNU Binutils for Windows (assembler, linker, archive manager)
  • A graphical and a command-line installer for MinGW and MSYS deployment on MS-Windows

MSYS, a contraction of "Minimal SYStem", is a Bourne Shell command line interpreter system. Offered as an alternative to Microsoft's cmd.exe, this provides a general purpose command line environment, which is particularly suited to use withMinGW, for porting of many Open Source applications to the MS-Windows platform; a light-weight fork of Cygwin-1.3, it includes a small selection of Unix tools, chosen to facilitate that objective, and using it is a necessary prerequisite for building mingwPORTs.

mingwPORTs are user contributed additions to the MinGW software collection. Rather than providing these "add-ons" as precompiled binary packages, they are supplied in the form of interactive Bourne shell scripts, which guide the end user through the process of automatically downloading and patching original source code, then building and installing it. Users who wish to build any application from a mingwPORTmust first install both MinGW and MSYS.

 

原创粉丝点击