mac 配置sublime text的C语言编译系统
在mac上配置subline,使其支持编译C语言,想想都好开森。
第一步,相信大家的电脑上都安装了subline,木有安装的自己可以去官网下载安装
第二步,需要你的mac安装gcc,已安装的请跳过
brew install gcc
安装过程大概5分钟的样子。
使用命令判断是否安装成功。
$ gcc -v Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn) Target: x86_64-apple-darwin14.1.1 Thread model: posix
第三步,配置subline text的c编译系统
打开Tools->Build System->New Build System,在新建的文件中输入以下内容:
{
    "cmd" : ["gcc -o ${file_base_name} $file_name"],
    "shell" : true,
    "working_dir" : "$file_path",
    "selector": "source.c",
    "encoding":"utf-8",
    "variants" :
    [{
        "name" : "Run",
        "cmd" : "./${file_base_name}"
    }]
}
编辑完成后,保存文件,命名为C.sublime-build,然后就可以在Tools->Build System中选中这个编译方式了,个人一般自动选中 Automatic
第四步,编辑hello.c文件
#include<stdio.h>
int main(){
    printf("hello world\n");
    return 0;
}
使用control+B进行编译文件,使用control+shift+B运行编译好的文件
效果如下:

参考文章
http://wenzhiquan.github.io/blog/2015/05/04/mac_os...
 
         
    
