标签:sublime text3编译运行c++ c++ 配置 编译 运行
1:新建文件 G++.sublime-build ,放置到 C:\Users\Administrator\AppData\Roaming\Sublime Text 3\Packages 中,文件中的内容为:{
"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}","-Wall" ],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"shell": true,
"encoding": "cp936",
"variants":
[
{
"name": "Run",
"cmd": [ "g++", "${file}", "-o", "${file_path}/${file_base_name}", "&","start", "C:/cb_console_runner.exe","${file_path}/${file_base_name}"]
}
]
}
2:从codeblocks里把 cb_console_runner.exe 复制一份直接放在C盘根目录下
3:配置环境变量
变量名:Path
变量值:codeblocks根目录\MinGW\bin
把上述 codeblocks根目录 改成你自己的 codeblocks根目录,我的根目录是 D:/codeblocks/CodeBlocks,所以我的变量值是 D:/codeblocks/CodeBlocks/MinGW/bin
win+R,cmd进入命令提示符,输入 g++ -v ,会出现一推文件,其中包括你的 codeblocks根目录\MinGW\bin 目录下的相关文件,我的是这样的
因为我的根目录是D:/codeblocks/CodeBlocks
4:用 Sublime Text3写一段C++代码进行测试
#include<iostream>
using namespace std;
int main(){
<span style="white-space:pre"> </span>int a,b,c;
<span style="white-space:pre"> </span>cin>>a>>b>>c;
cout<<"a="<<a<<" b="<<b<<" c="<<c<<" succeed run C++"<<endl;
return 0;
}
按Ctrl+B进行编译,按Ctrl+Shift+B进行运行,如图
配置成功,恭喜你从此可以愉快的写C++程序了!
标签:sublime text3编译运行c++ c++ 配置 编译 运行
原文地址:http://blog.csdn.net/qq_21682823/article/details/46054969