1、下载并安装Dev-Cpp_5.11_TDM-GCC_4.9.2_Setup.exe。完成安装后,查找gcc.exe/g++.exe文件所在路径,比如我的:D:\Dev-Cpp\MinGW64\bin,记下。
2、将gcc.exe/g++.exe所在路径添加环境变量中。方法见我的上一篇文章,同时再新建两个用户变量:
a.C_INCLUDEDE_PATH值D:\Dev-Cpp\MinGW64\include
b.LIBRARY_PATH值D:\Dev-Cpp\MinGW64\lib
3、验证上面配置是否成功。方法:重新打开一个cmd命令窗体(一定要重新打开一个新的命令窗体),输入命令gcc -v查看是否会提示gcc的版本,有提示则表示上面步骤已成功,如下图:
4、创建c/c++编译系统:运行Sublime Text2,选择工具 --> 编译系统 -->
新建编译系统...,在新弹出的窗体中,把默认内容({ "cmd": "make"}}替换成
{
"cmd": ["g++", "-std=c++11", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
"cmd": ["cmd", "/c", "g++", "-std=c++11", "${file}", "-o", "${file_path}/${file_base_name}", "&&", "cmd", "/c", "${file_path}/${file_base_name}"]
},
{
"name": "RunInCommand",
"cmd": ["cmd", "/c", "g++", "-std=c++11", "${file}", "-o", "${file_path}/${file_base_name}", "&&", "start", "cmd", "/c", "${file_path}/${file_base_name} & pause"]
}
]
}
(如下图),保存在默认的目录下即可,注意修改文件名为c++.sublime-build 。重启sublime
text,就可以用Ctrl+B来编译.c/cpp文件了;
5、运行: