【前提】
系统:XPSP3
【步骤】
1. 下载MinGW-5.1.6.exe(网络安装)和gdb-6.3-2.exe运行MinGW-5.1.6.exe 又下载了如下安装包:
binutils-2.19.1-mingw32-bin.tar.gz
gcc-core-3.4.5-20060117-3.tar.gz
gcc-g++-3.4.5-20060117-3.tar.gz(需要在默认的core外令选)
mingw32-make-3.81-20080326-2.tar.gz(需要在默认的core外令选)
mingwrt-3.15.2-mingw32-dev.tar.gz
mingwrt-3.15.2-mingw32-dll.tar.gz
w32api-3.13-mingw32-dev.tar.gz
2. 下载完毕后自动安装。
3. 安装完毕后运行gdb-6.3-2.exe
4. 设置环境变量。
Path
C:/MinGW/bin;C:/MinGW/libexec/gcc/mingw32/3.4.5;
C_INCLUDE_PATH
C:/MinGW/include;C:/MinGW/lib/gcc/mingw32/3.4.5/include
C_PLUSE_INCLUDE_PATH
C:/MinGW/include/c++/3.4.5;C:/MinGW/include/c++/3.4.5/mingw32;C:/MinGW/include/c++/3.4.5/backward;%C_INCLUDE_PATH%
LIBRARY_PATH
C:/MinGW /lib; C:/MinGW /lib/gcc/mingw32/3.4.5
5. 运行g++ - -version
g++ (GCC) 3.4.5 (mingw-vista special r3)
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.
6运行测试代码:
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
cout << "Yeah, MinGW!" << endl;
return 0;
}
保存为main.cpp
在cmd下面输入编译命令
g++ -o test main.cpp
这次是什么都没看到就是成功了。
接着输入test.exe
看见以下的信息了么
Yeah, MinGW!