1、下载MinGW
MinGW,是Minimalist GNUfor Windows的缩写。它是一个可自由使用和自由发布的Windows特定头文件和使用GNU工具集导入库的集合,允许你在GNU/Linux和Windows平台生成本地的Windows程序而不需要第三方C运行时(C Runtime)库。
2、配置环境变量,设置系统变量Path
3、配置Sublime Text 3
(1)Tool >> Build System >> New Build System >> 复制如下代码,保存为C.sublime-build >> 重启Sublime Text 3
{
"working_dir": "$file_path",
"shell_cmd": "g++ -Wall -std=c++0x \"$file_name\" -o \"$file_base_name\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"selector": "source.cpp",
"variants":
[
{
"name": "RunInCmd",
"shell_cmd": "g++ -Wall -std=c++0x \"$file\" -o \"$file_base_name\" && start cmd /c \"\"${file_path}/${file_base_name}\" & pause \""
}
]
}
(2)Tool >> Build System >> C(新的选项)
(3)Tool >> Build With >>C RunInCmd
(4)测试
4、查看C.sublime-build文件
(1)Preferences >> Browse Packages >>User
5、设置运行快捷键
(1)Preferences >> Key Binding >>添加如下代码 >> 重启Sublime Text 3
{
"keys":["f2"],
"command":"build","args":{"variant":"RunInCmd"}
}