一、MinGW安装
MinGW官方网址:http://www.mingw.org/
下载地址:http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/
进入网站后点击Download
即可得到安装程序.exe
运行Setup
,并且点击Install
在此选择安装目录
勾选我们需要的Package,并选择Mark for Installation
点击Installation
->Apply Changes
.如下图所示
点击Apply
,安装完成
二、设置环境变量
此电脑
右键->属性
->高级系统设置
->环境变量
点击编辑
,在Path中增加刚才安装的MinGW文件的bin文件夹下
在cmd中输入g++ -v
或gcc -v
便可以查看当前是否下载成功
三、MinGW的使用
测试C++文件test.cpp
,代码如下
#include<iostream>
using namespace std;
int main()
{
string str;
cout << "please enter your name\n";
cin >> str;
cout << "Hello," << str <<"!\n";
}
在cmd中输入如下编译命令g++ test.cpp -o test
然后输入test
,回车执行