In general C codes written in Unix can’t be compiled in Windows OS. Unix has some special system calls(like fork, spawn, signals, select, sockets and so on) which Windows doesn’t has, but Windows has other APIs with same function in that these two kinds of OS all comply with ANSI C standard. So, fork can’t be called in Windows but Windows usesCreateProcess to accomplish the same function.
MinGW and Cygwin supply two types of C compiler to realize that programmers can code Unix C in Windows environment.
1. MinGW gcc compiler converts Unix calls to Windows APIs in equivalent in the progress of compile.
2.Cygwin gcc compiler is same to the gcc in Unix, for the purpose, it adds one filecygwin1.dll to each application to translate Unix system calls to Win APIs at runtime. Consequently, codes can be run in two OS seamlessly.
Now we can see that Cygwin would be better if your codes ran in Unix but developed in Windows. On the ohter hand, MinGW can compile a pure Win32 application from your Unix codes. Moreover the speed of applications compiled by MinGW is faster than those by Cygwin because the latter has an additional translating process at runtime executed incygwin1.dll.
BTW: If you want to get MinGW RAR bag in size of 24MBytes, I’m glad to mail it to you. You can get my email in URl http://blog.classky.com/about/, and please ensure your mailbox could support the size of attachment. (中文版请点击更多)
通常情况下Unix下编译通过的C代码在Win32下编译是不能通过的,虽然大多数函数调用在Unix和Win32下是相同的,但是Unix有自己一些独特的系统调用如fork,spawn,signals,select,sockets等),如果代码中使用了这些系统调用,在Win32环境下运行的时候自然是找不到对应的库的。Windows提供的程序接口叫API(其实就是系统调用),它虽然函数名字和Unix下的不一样,但功能确是一样的。如Unix下的fork在Windows中对应的API就是CreateProcess.
所以如果你想在Windows上开发/编译Unix代码,可以有两种方法:
1、让Windows下的C语言编译器在编译期间将Unix代码中的特殊系统调用转换成相应的Windows API形式,MinGW就是这么做的。
2、编译器还是用Unix的编译器,在每个程序运行期间,当他要执行Unix系统调用时,由一个额外的动态链接库(这是Windows特有的东西,说白了就是一组函数库,在程序运行期间可以动态加载和卸载)将它翻译成Windows API,这就是Cygwin的做法,这个DLL就是cygwin1.dll。
由些可见,MinGW相比Cygwin来讲更加贴近win32,因为它几乎支持所有的Win32API。它所连接的程序,不需要任何第三方库即可运行,速度较快。但Cygwin编译出来的C代码就等同于Unix环境下编译出来的,所以可以不经修改直接运行在Unix平台,如果要在Windows上运行,加载一个cygwin1.dll就可以了,虽然速度上有点影响,但是实现了跨平台的代码开发。具体选用哪一个,就看各自的需要了。当然如果你只要开发Windows应用程序的话,就要费神想这么多了,VC、BC等都是现成的编译平台。
参考http://www.livinchina.info/2008/11/27/difference-of-gcc-compiler-between-mingw-and-cygwin/
相关推荐
mingw64 32 gcc编译器安装包
目前适用于 Windows 平台、受欢迎的 GCC 移植版主要有 2 种,分别为 MinGW 和 Cygwin。其中,MinGW 侧重于服务 Windows 用户可以使用 GCC 编译环境,直接生成可运行 Windows 平台上的可执行程序,相比后者体积更小,...
MinGW(Minimalist GNU on Windows),将经典的开源 C语言 编译器 GCC 移植到了 Windows 平台下,并且包含了 Win32API ,因此可以将源代码编译为可在 Windows 中运行的可执行程序。而且还可以使用一些 Windows 不...
MingW 是将C语言编译器 GCC 移植到了 Windows 平台下
matlab_MinGW_w64编译器,官网下载,【不建议用积分下载博主的这个文件,积分超多的博友除外,因为官网上有现成免费的,只是外国网站打开较慢】)官网打开较慢,重复多次能打开。想省时间可以点此下载。可参考博主...
解压完MinGW.7z文件后,配置完环境变量,编写一个c/c++程序hello.c/hello.cpp原代码,cmd进入windows命令行后,cd进入到当前hello.c或hello.cpp源代码所在路劲下,使用...这个东西还可以作为CodeBlocks的gcc编译器用。
2020-03-16生成的 mingw-w64 7.0.0 gcc 9.3.0 binutils 2.34 gdb 9.1 make 4.2.1 目前只在x64版Win10测试通过。
MinGW Object-C编译器,直接解压到MinGW目录中即可
C , C++语言在windows下的编译器,gcc版本6.30,支持C++14标准
支持c/c++文件编译,使用见《matlab整合libsvm-alixia》
如题,QT5.14.1下基于minGW73_32编译器的mysql数据库的编译结果,经测试可直接替换,不需要自己重新编译
省去国外网站下载环节。直接下载作者之前下载好的文件(mingw32-gcc-Fortran),然后添加路径和验证,即可使用。
MinGW: A collection of freely available and freely distributable Windows specific header files and import libraries, augmenting the GNU Compiler Collection, (GCC), and its associated tools, (GNU ...
mingw资料 C++编译器配置。 初学C/C++的人,想要写程序,运行程序,首先要配置C/C++的编译环境,主要讲解MinGW的配置和相关开发环境的使用
gcc版本是 9.2.0-2,解压后把MinGW\bin配置到path,Eclipse IDE for C/C++ Developers等开发工具 即可自动识别(Eclipse for C/C++ 2018-09 测试通过 ),然后就可以用Eclipse等开发工具学习和开发C或C++程序。...
预编译Mingw64位,下载自google code achive
Win32的全功能集成开发环境(IDE)。它使用GCC,Mingw或Cygwin作为编译器和库集。
Matlab安装 MinGW-w64 编译器。 包括下载好的MinGW-w64 C/C++和 简单的安装步骤(Readme.doc)
gcc 编译器的windows版本,可以采用两种安装方法的,里面有介绍。
gcc7.2 mingw w64 编译器 非常好用,支持C++17 替换devCPP的mingw后,修改编译参数为-std=C++1z即可使用