brew install gcc
安装过程大概5分钟的样子。c++
使用命令判断是否安装成功。git
$ 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
打开Tools->Build System->New Build System,在新建的文件中输入如下内容:github
{ "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中选中这个编译方式了,我的通常自动选中 Automaticshell
#include <stdio.h> int main(){ printf("hello world\n"); return 0; }
使用control+B进行编译文件,使用control+shift+B运行编译好的文件app
效果以下:svn
参kao文章ui
http://wenzhiquan.github.io/blog/2015/05/04/mac_os_yosemite_sublime_and_c/spa