Monday, November 28, 2016

How to Build/Compile and Run C/C++ in Sublime Text 3

Last Update:

Recommended Cloud & Hosting: Cloudways, Hostinger & BlueHost
Obviously, Sublime Text 2 or 3 is a popular cross-platform source code editor and compiler for compiling and running programming code including C/C++. If you want to know more about Sublime Text or want to download and install, you can check there.
You can compile, build and run on Sublime text c++ compiler. But you have to enable Sublime build system C++ or Sublime build system C.
Compile and Run C/C++ in Sublime Text 3
Compile C/C++ in Sublime Text 3


After installing to compile and run C++, firstly you have to installed G++ for C++ and GCC for C. You can check whether G++ is installed on your Ubuntu by running the following command:
dpkg --list | grep compiler  
If you didn't install this, you must have install. To compile C++ on Sublime Text 3, follow the below step by step:

Step-1: Open/Launch Sublime Text 3

Step-2: Copy the following code.
{
"cmd" : ["gcc $file_name -o ${file_base_name} && ./${file_base_name}"],
"selector" : "source.c",
"shell": true,
"working_dir" : "$file_path"
}
Step-3: Go to Tools -> Build System -> New Build System.

Step-4: Paste the copied code.

Step-5: Save this by naming C++ with .sublime-build (Example: C++.sublime-build) extension at the default location   username → .config → sublime-text-2 → Packages → User

Now your Sublime Text 3 is ready for compiling and running C++. To enable your customized C++ profile, just go to Tools -> Build System -> and check C++.

You can compile and run C while saving your c file with extension .cpp
If you have any problem to customize this or this article help you, please comment. Happy Coding !

Related: Compile C/C++ on Ubuntu Terminal.

About me


Elliyas Ahmed
Elliyas Ahmed

Hi, I am Elliyas Ahmed, the founder of ComProMath. I try to share what I learn.

Work With Me - SEO Expert, WordPress, Blogger Theme Developer on Fiverr

Lets Disucss on this Article

Don't try SPAMMING here! Submit your Feedback, Questions or Comment related to this Article. Read our Comment Policy.