5 Secrets of Blogger (Service) You Don't Know

Recent Posts

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

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.