Sublime Text C Cpp Build System for GCC On Windows And Linux

Just paste this code in a plain text file and save the file as "NAME.sublime-build" in C:\Documents and Settings\USERNAME\Application Data\Sublime Text 3\Packages\User folder.

-You can replace "NAME" with any text you like.

-The 'Application Data ' folder is a hidden folder.Goto Tools menu and mark 'Show hidden files and folders' to view it. If this isn't clear there are lots of tutorials online. Just search for 'view hidden files in windows'.

-Finally, Open Sublime Text, Goto Tools->Build System. Then click on the NAME. That's it. You should be able to run, provide input and  see output in Sublime Text itself. Just make sure the C++ file you are working on should be saved in same folder with 'inputf.in' and 'outputf.in'. If you haven't already, create two files named 'inputf.in' and 'outputf.in' in the folder in which you are going to save your C++ file.

-Don't forget to save the file before trying to compile or run it!

-Comment if you run into issues. Also you can e-mail me.

Windows:
{
"cmd": ["g++.exe", "-std=c++11", "${file}", "-o", "${file_base_name}.exe", "&&" , "${file_base_name}.exe<inputf.in>outputf.in"],
"shell":true,
"working_dir":"$file_path",
"selector":"source.c"
}


Linux:
{ "cmd" : ["g++ -std=c++11 $file_name -o $file_base_name && timeout 4s ./$file_base_name<inputf.in>outputf.in"], "selector" : "source.c", "shell": true, "working_dir" : "$file_path" }

Comments