Sublime Text C++ Compiler Mac

Sublime Text is an amazing code editor that you can use for many programming languages including C. It is also the best IDE for c. This is a very fast text editor, with a simple UI. This software is very easy to use. Hey, in this article you will learn how to setup C/C in sublime editor with input features and much more also stay intact for a bonus tip at the end!! Follow this steps for a successful set up: Head over to your browser and search for sublime text 3!

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'.

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).

SublimeSublime text c++ compiler machineBest c++ compiler macC++ compiler for sublime text

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'.

Sublime Text C++ Compiler

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).

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++.

Install Sublime Text 3

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.

Sublime Text C++ Plugin

Thanks

Comments are closed.