sublime配置C语言和c++编译环境

来源:互联网 发布:python 登录界面 编辑:程序博客网 时间:2024/06/08 18:02

在sublime text3 中选择Tools->Build System->New Build System

此时就会打开一个含有配置文件编辑的页面,先以c为例,将下列代码复制到里面

{
"working_dir": "$file_path",
"cmd": "gcc -Wall \"$file_name\" -o \"$file_base_name\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"selector": "source.c",
 
"variants": 
[
{
"name": "Run",
        "shell_cmd": "gcc -Wall \"$file\" -o \"$file_base_name\" && start cmd /c \"\"${file_path}/${file_base_name}\" & pause\""
}
]
}

保存,将文件名保存untitled.sublime-build中的untitled改为自己设置的名字,比如我的就是myc.sublime-build,然后在Build System中就可以看到自己的编译系统了,c++也是如此,不过将代码改一下

{"cmd": ["g++", "${file}", "-o","${file_path}/${file_base_name}"],"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:?(.*)$","working_dir": "${file_path}","encoding":"cp936","selector": "source.c","variants":[{"name": "Run","cmd": ["cmd","/C","start","cmd","/c", "${file_path}/${file_base_name}.exe &pause"]}]}
现在还有一个中文在cmd中显示乱码的问题,路过的大神,在评论区留下你们的方法,甚是感谢