Sublime Text C++/CPP Build System under MacOSX Yosemite

Using the ever-so-wonderful Sublime Text as your primary editor is a joy in itself, however, building your .cpp files under OS X with it was something I wasn’t able to do out-of-the-box. Here are the steps that would enable you start compiling in no time – and as always, you need to have Xcode installed with its’ command line tools in order for any of this to work properly.


  1. Go to this site: and follow the installation instructions
  2. After you’re done, open Package Control in Sublime by pressing ctrl + shift + p
  3. Search and install the following: ” C++ Starting Kit
  4. Create a the following file:
    /Users/yourusername/Library/Application Support/Sublime Text 3/Packages/User/C++.sublime-buildPaste this into the newly created C++.sublime-build file:

"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"name": "Run",
"cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]

About the author

Gábor Hargitai

View all posts