一、安装GCC编译器,我安装的是tdm64-gcc-5.1.0-2。
下载链接:
http://tdm-gcc.tdragon.net/download
二、配置Sublime的Build配置文件。
1, 打开Sublime Text,点击Tools->Build System->New Build System
2, 输入以下内容
{
"cmd": ["g++", "-Wall","-fexceptions", "-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++",
"encoding":"cp936",
"variants":
[
{
"name": "Run",
"cmd": ["cmd", "/c", "g++", "-Wall","-fexceptions", "-g", "-std=c++11", "${file}", "-o", "${file_path}/${file_base_name}",
"&&", "cmd", "/c", "${file_path}/${file_base_name}"
]
},
{
"name": "RunInCommand",
"cmd": ["cmd", "/c", "g++","-Wall","-fexceptions", "-g", "-std=c++11","${file}", "-o", "${file_path}/${file_base_name}",
"&&", "start", "cmd", "/c", "${file_path}/${file_base_name} & echo.&pause"
]
}
]
}
保存为NewC++.sublime-build
该文件位置:Sublime Text 2.0.2 x64\Data\Packages\User
3, 选定Tools->Build System->NewC++
在C++源文件中按Ctrl+B编译,Ctrl+Shift+B执行。
搞定。