在linux或者mac os中我们选择【工具 / 编译系统 / c++(tools / build system / c++)】就可以配置c/c++的编译环境,但是在windows环境下,我们却需要做更多的设置
首先我们需要设置mingw编译器的环境变量,使我们可以直接使用gcc/g++命令,这点我们就不重复了,不会的请大家自行脑补
我们直接讲sublime text的配置方法
工具 / 编译系统 / 编译新系统(tools –> build system –> new build system)
粘贴下面的代码,保存为c++build.sublime-build
{
"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}.exe"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c++",
"encoding": "cp936",
"shell": true,
"variants":
[
{
"name": "run",
"cmd": ["start","d:/安装软件/codeblocks/cb_console_runner.exe","${file_path}/${file_base_name}"]
}
]
}
下面我们写一个测试程序
#include <stdio.h>
#include <stdlib.h>
int main(void)
int left, right;
while(scanf("%d %d", &left, &right) != eof)
{
printf("%d\n", left + right);
}
return exit_success;
按下ctrl+b【工具 / 编译(tools / build)】
然后按下ctrl+shift+b,运行
转载:http://blog.csdn.net/gatieme/article/details/42807141