Hi, I actually wanted to compile some C from sublime text 2 today but find out there wasn’t build system for that. I’ve read documentation a bit and came up with this:
{
"cmd" : "gcc", "$file_name", "-o", "${file_base_name}.exe"],
"selector" : "source.c",
"working_dir" : "$file_path"
}
It should compile C as well as C++ code. It works well but I couldn’t get it to execute the program after it’s finished which is actually what I was hoping to achieve. If anyone knows how to run program after it was compiled, I’d be very grateful. I’ve tried this:
{
"cmd" : "gcc", "$file_name", "-o", "${file_base_name}.exe && ${file_base_name}.exe"],
"selector" : "source.c",
"working_dir" : "$file_path"
}
But it doesn’t work. I just get exe file named “test.exe && test.exe”. Probably because sublime feeds array fields as arguments for the gcc instead of just creating a string and executing it in cmd.
Note: you don’t need “.exe” if you’re on unix system.