1.gcc
gcc(GNU Compiler Collection)是一款优秀的c++编译器,同时他也是gnu计划的一部分。
gcc最初只能在unix或linux环境中使用,后来出现了mingw,这样gcc就能够在windows环境下使用了。
2.安装mingw
mingw可以直接安装也可以通过安装Qt creator来实现间接安装。我这里是通过安装qtcreator-2.4.1来实现mingw安装的。
安装后,mingw的目录为C:\Qt\qtcreator-2.4.1\mingw。
3.环境变量配置
在用户变量里加入inclue和Path,分别为C:\Qt\qtcreator-2.4.1\mingw\include和C:\Qt\qtcreator-2.4.1\mingw\bin
4.编译连接
此时你已经可以在cmd下使用gcc命令了
下面一段代码
// hello.cpp
#include <iostream>
int main()
{
std::cout << "Hello,World!\n";
}
在cmd下切换目录到该cpp当前目录下
然后执行gcc -o hello hello.cpp
很快就能编译连接出一个可执行文件hello.exe
在cmd下直接运行就能显示Hello,World!