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.
- Go to this site: https://packagecontrol.io/installation and follow the installation instructions
- After you’re done, open Package Control in Sublime by pressing ctrl + shift + p
- Search and install the following: ” C++ Starting Kit “
- 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++",
"variants":
[
{
"name": "Run",
"cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
}
]
}