MinGW
Minimalist GNU for Windows,前身為mingw32,是一個免費開源的軟件開發環境,從2010年開始項目停止并不再使用。后續提供MinGW-w64。
MinGW包括:
?- 移植到Windows上的GNU編譯器集(GCC),包括C、C++、ADA和Fortran編譯器。
?- 適用于Windows的GNU Binutils(匯編器、鏈接器、歸檔管理器 / assembler, linker, archive manager)
MinGW的用途是什么?
MinGW是一個基于GNU GCC和Binutils項目的編譯器系統,它可以將代碼編譯和鏈接到Win32(Windows)系統上運行,生成本地微軟Windows應用程序。它提供C、C++和Fortran編譯器以及其他相關工具。
What is the use of MinGW?
MinGW is a compiler system based on the GNU GCC and Binutils projects that compiles and links code to be run on Win32 (Windows) systems. It provides C, C++ and Fortran compilers plus other related tools.
所以,通俗的說,MinGW就是用你在Linux上習慣的方式來使用GCC在Windows平臺上編碼并生成可運行的Windows程序。
MinGW是一個在Windows平臺上使用的完整的GCC工具鏈(包括部分前端功能,如C、C++、Ada、Go等編程語言的編譯),代碼編譯和鏈接過程中使用的是Windows操作系統組件C運行時庫msvcrt.dll。它試圖盡可能做到最簡最少最小(因此而得名)。
MinGW并不試圖在Windows之上提供一個完整的POSIX層,它也不要求你與一個特殊的兼容庫鏈接(如上所說,只使用了Windows系統自帶的庫,并不依賴于任何第三方C-Runtime DLLs)。
Cygwin is a POSIX emulation layer, while MinGW provides functions supplied by the Win32 API. MinGW-w64 is a fork of MinGW that supports 64-bit Windows.
MinGW-w64
https://www.mingw-w64.org/
Mingw-w64 is an advancement of the original mingw.org project, created to support the GCC compiler on Windows systems. It has forked it in 2007 in order to provide support for 64 bits and new APIs. It has since then gained widespread use and distribution.
Mingw-w64是原mingw.org項目的一個進化版,用于在Windows系統上支持GCC編譯器。它在2007年從原MinGW分支出來,以提供對64位和新的API的支持。此后,它獲得了廣泛的使用和傳播。
較新的MinGW-w64帶有大約99%完整的Windows API綁定(不包括ATL等),包括x64支持和實驗性ARM實現。你可能偶爾會發現一些奇特的常量未被定義,但對于99%的人在99%的時間內使用的東西,它工作得非常好。
https://sourceforge.net/projects/mingw/
MinGW: A native Windows port of the GNU Compiler Collection (GCC), with freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All of MinGW's software will execute on the 64bit Windows platforms.
Downloads - MinGW-w64
https://www.mingw-w64.org/downloads/
選擇MinGW-W64-builds,這個是純Windows平臺使用的。其他的很多就是其他平臺下使用MinGW-w64,是交叉編譯了,比如在Ubuntu下使用MinGW,編譯出可以在Windows下執行的程序。
再比如,Cygwin里,MinGW作為一個包,可以安裝。裝完后,就可以使用MinGW作為交叉編譯器,編出在Windows下運行的exe文件了。
下載地址:https://github.com/niXman/mingw-builds-binaries/releases
關于MinGW,可選Architecture : i686和x86_64,可選Threads Model種類:posix、win32和MCF,可選Exception:seh和silj,第二個之前版本有,現在沒了。
可選的C運行庫:msvcrt和ucrt。
i686平臺下,只有dwarf一種選中,是一種調試信息文件格式。
14.2是gcc的版本,v12-rev0是MinGW-w64的發布版本。
下載壓縮文件后,解壓縮到合適路徑。
MinGW目錄下的bin路徑,要加入到系統環境變量中,在System variables的Path中。
然后打開命令行,就可以執行gcc --version了。
使用gcc編譯C代碼,就會得到可執行的exe文件。
在Windows下使用MinGW的好處,方便了在Linux下用慣了GCC套件的開發者,并跟隨GCC版本更新。如前面可選的MinGW版本所列,MinGW編譯器既可以使用Windows API編程,也可以使用POSIX編程。
??
MinGW-w64
MinGW is an abbreviation of Minimalist GNU for Windows. The idea of MinGW is to provide a development platform for building cross-platform applications on Windows. The important pieces are:
* a set of FOSS Windows specific header files and import libraries which enable the use of the Windows API,
* a supplementary library and a runtime that fill in some gaps.
... but the term generally encompasses the cross-platform GNU development tools:
* GNU Compiler Collection (GCC),
* GNU Binutils (assembler, linker, archive manager),
* GNU Debugger (GDB),
* and miscellaneous utilities.
There are at least two projects implementing this idea:
* the original MinGW project, sometimes referred to as mingw.org
* and the MinGW-w64 project.
The MinGW-w64 project itself doesn't aim to be a software distribution. There are multiple builds of mingw-w64 toolchains and multiple software distributions built using MinGW-w64.
參考:
MSYS2 History - MSYS2