<pre name="code" class="html">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. (It does 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 applications must 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 consider Cygwin 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 command-line installer, with optional GUI front-end, (mingw-get) for MinGW and MSYS deployment on MS-Windows
A GUI first-time setup tool (mingw-get-setup), to get you up and running with mingw-get.
1.下载路径:http://sourceforge.net/projects/mingw/files/latest/download?source=files
2. 运行mingw-get-setup.exe之后,一步一步,会打开一个graphic management installer,选择需要安装的compiler。
也可以通过命令行来安装:
2.1 把安装目录下的bin添加到path环境变量下。
2.2
mingw-get install gcc g++ mingw32-make 会安装c/c++编译器和mingw32-make
3. 在D:\python\workspace有一个文件test.c 是一段简单的c代码:
#include <stdio.h>
void main() {
printf("Hello World!\n");
printf("total num is %d",count(10,20));
}
int count(int a,int b)
{
printf("value of a is %d, value of b is %d \n",a,b);
return a+b;
}
3.1编译test.c成test.o
cd到workspace目录下:gcc -c test.c
【3.2.1】把test.o编译成可执行二进制文件test.exe
gcc -o test test.o
【3.2.2】
也可以一个命令实现1/2两步:
gcc test.c -o test
3.3 运行test.exe
在命令行:test
输出结果为:
D:\python\workspace\cTestProject>test
Hello World!
value of a is 10, value of b is 20
total num is 30