Sublime Text C++ Compiler Mac

There are many things that I find missing in default C++ build in Mac Sublime Text(clang) like no bits/stdc++.h header, regular warnings on using auto keyword, using inline comparator functions etc. So I tried searching how to use brew's g++ as default build in Sublime Text without breaking anything but couldn't find anything.

First of all install brew from brew.sh.

After that install gcc using the command in terminal 'brew install gcc'.

C11 features usage. Here you will need a custom build system for Sublime text. It's easy to create! 3 easy steps again. 1) Download gpp.sublime-build from my GitHub. 2) Go to Sublime, then select Tools-Build System-New Build System. This is the place where you should paste gpp.sublime-build. Don't forget to save the file. All global configuration for Sublime (including installed packages) is stored in /.config/sublime-text-3 (or%APPDATA Sublime Text 3 on Windows, or /Library/Application Support/Sublime Text 3 on Mac). We will reference the Linux folder for the rest of this tutorial, but replace with your own path if using a different OS.

Best C++ Compiler Mac

Check if install is complete using command 'gcc-11 --version' (I got gcc-11 installed, in future you may use gcc-12,gcc-13 etc).

Sublime Text C++ Compiler Macro

Now type the command 'which g++-11' to get the location where g++-11 got installed. Copy this location ( Mine was something like — /opt/homebrew/bin/g++-11 ).

Open sublime text and install 'PackageResourceViewer' from Package Control. After that open command palette and open 'PackageResourceViewer: Open resource'.

  • Hello r/mac!I'm a first time poster, first time mac owner, first time c programmer, and taking a c programming class which uses visual studio. Because I don't really understand the lingo yet, I'm not really sure what to search for, but since I need to work on visual studio projects on my mac, I need a simple text editor without a dependancy on project structure (like sublime, brackets.
  • Compile and build C code in Sublime Text (Mac) using brew g instead of default build (clang) By NNIIT, 2 weeks ago, There are many things that I find missing in default C build in Mac Sublime Text(clang) like no bits/stdc.h header, regular warnings on using auto keyword, using inline comparator functions etc.

Then go to C++.

Then go to C++ Single file.

Finally replace all g++ with the location we copied earlier (/opt/homebrew/bin/g++-11).

Typescript Sublime Plugin

Sublime text c++ compiler mac

Save this file using cmd+s and restart sublime text. Compile and build as you would usually do in sublime text (cmd+b/cmd+shift+b) and this time it would build using brew's g++.

If you would like to revert back to original g++, just go back to C++ Single file build and change '/opt/homebrew/bin/g++-11' to 'g++' wherever applicable.

Thanks

Comments are closed.