0. mingw-get-setup.exe
首先,你需要安装一个 mingw-get-setup.exe(点击参考这篇文章,记得安装好 mingw并配置环境变量)
1. 创建 build system
点击 tools - build sysem - new build system,输入下面的代码
{
"cmd": ["g++", "${file}", "-std=c++11", "-o", "${file_path}\\\\${file_base_name}", "&", "start", "cmd", "/c", "${file_path}\\\\${file_base_name} & echo. & pause"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", "working_dir": "${file_path}",
"selector": "source.c, source.c++", "shell": true,
"encoding":"cp936",
"variants":
[
{
"name" : "Build Only",
"cmd":["g++", "${file}", "-std=c++11", "-o", "${file_path}\\\\${file_base_name}"]
},
{
"name" : "Run Only",
"cmd" : ["start", "cmd", "/c", "${file_path}\\\\${file_base_name} & echo. & pause"]
},
{
"name" : "Pipe Build and Run",
"cmd":["g++", "${file}", "-std=c++11", "-o", "${file_path}\\\\${file_base_name}","&","${file_path}\\\\${file_base_name}", "<","${file_path}\\\\in",">","${file_path}\\\\out"]
},
{
"name" : "Pipe Run Only",
"cmd" : ["${file_base_name}", "<","in",">","out"]
},
{
"name" : "Project Build & Run",
"cmd" : ["g++", "${file_path}\\\\*.cpp", "-std=c++11", "-o", "${file_path}\\\\project", "&", "start", "cmd", "/c", "${file_path}\\\\project & echo. & pause"]
},
{
"name" : "Project Build Only",
"cmd" : ["g++", "${file_path}\\\\*.cpp", "-std=c++11", "-o", "${file_path}\\\\project"]
},
{
"name" : "Project Run Only",
"cmd" : ["start", "cmd", "/c", "${file_path}\\\\project & echo. & pause"]
}
]
}
保存为 C++.sublime-build,保存位置默认
接着,点击 tools - build system - 选择 C++
如果有调试需求,可以安装插件 SublimeGDB
2. 测试
创建一个 test.cpp
#include <iostream>
using namespace std;
int main(){
cout << "hhh" << endl;
return 0;
}
按下ctrl + shift + B,会出现下面的选项:
选择第一个编译运行,输出正常~
REFERENCE:
1881

被折叠的 条评论
为什么被折叠?



