原文:http://hi.baidu.com/%D6%C7%B4%EF%B8%DF%D4%B6lee/blog/item/ee07d43351288da25edf0e13.html
到http://sourceforge.net/projects/mingw/ 手动去下载最新的MinGW,或使用MinGW-5.1.4.exe,自动下载。但后者往往不能下载到最新的稳定包。
1、手动下载说明,参见:http://www.mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite
可从:http://sourceforge.net/projects/mingw/ 选择包下载。
2、运行 MinGW-5.1.4.exe 的话,选择 Candidate,一般会下载最新的包,选择如下几项:
MinGW base tools
g++ compiler
MingGW Make
默认路径C:/MinGW,我装在 D:/cplusplus/mingw
根据:http://wiki.codeblocks.org/index.php?title=MinGW_installation,需要下载如下必要的包:
* http://prdownloads.sf.net/mingw/gcc-core-3.4.5-20060117-1.tar.gz
* http://prdownloads.sf.net/mingw/gcc-g++-3.4.5-20060117-1.tar.gz
* http://prdownloads.sf.net/mingw/mingw-runtime-3.9.tar.gz
* http://prdownloads.sf.net/mingw/mingw-utils-0.3.tar.gz
* http://prdownloads.sf.net/mingw/w32api-3.6.tar.gz
* http://prdownloads.sf.net/mingw/binutils-2.17.50-20060824-1.tar.gz
* http://prdownloads.sf.net/mingw/mingw32-make-3.81-1.tar.gz
另外一个是调试器:
* http://prdownloads.sf.net/mingw/gdb-6.3-2.exe
安装完后就配置环境变量吧。
控制面板--〉系统--〉系统详细设置--〉环境变量
MINGW_PATH=D:/cplusplus/mingw
C_INCLUDE_PATH=%MINGW_PATH%/include;%MINGW_PATH%/lib/gcc/mingw32/3.4.5/include
CPLUS_INCLUDE_PATH=%MINGW_PATH%/include/c++/3.4.5;%MINGW_PATH%/include/c++/3.4.5/mingw32;%MINGW_PATH%/include/c++/3.4.5/backward;%C_INCLUDE_PATH%
LIBRARY_PATH=%MINGW_PATH%/lib;%MINGW_PATH%/lib/gcc/mingw32/3.4.5
PATH=%MINGW_PATH%/bin;%MINGW_PATH%/libexec/gcc/mingw32/3.4.5
注意:上面的很多3.4.5这个是gcc的版本号,要以真实的文件夹为准。
现在开一个CMD吧
输入g++ --version
看到以下信息的话就成功一半了。
g++ (GCC) 3.4.5 (mingw special)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
继续新建一个test.cpp文件
内容如下
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
cout << "Yeah, MinGW!" << endl;
return 0;
}
在cmd下面输入编译命令
g++ -o test test.cpp
这次是什么都没看到就是成功了。
接着输入test.exe
看见以下的信息了么
Yeah, MinGW!
现在,可以在XP下面编写你的C或者C++程序了。