Sublime Text2上搭建C/C++环境
环境:Sublime Text2
win7 64位
1.下载Sublime Text2并安装
2.需要用到gcc/g++编译器,下载MinGW并安装
3.配置MinGW环境:
把MinGW的安装路径:“c:\MinGW\bin”(这是c盘)添加到环境变量里
4.配置ST环境
#1.找到:Tools –> Build System –> New Build System…
#2.把如下内容保存为:C++Bulider.sublime-bulid
{ "cmd":["g++","${file}","-o","${file_path}/${file_base_name}"],//For GCC OnWindowsandLinux //"cmd":["CL","/Fo${file_base_name}","/O2","${file}"],//For CL on WindowsOnly "file_regex":"^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", "working_dir":"${file_path}", "selector":"source.c, source.c++", "variants": [ { "name":"Run", //"cmd":["bash","-c","g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]//LinuxOnly "cmd":["CMD","/U","/C","g++ ${file} -o ${file_base_name} && ${file_base_name}"]//For GCC OnWindowsOnly //"cmd":["CMD","/U","/C","CL /Fo${file_base_name} /O2 ${file} && ${file_base_name}"]//For CL OnWindowsOnly } ] }
5.编写代码
新建文件:demo.c
#include<stdio.h> int main() { printf("hello world!\n"); return0; }
使用Ctrl+B编译,使用Ctrl+Shift+B运行