Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime text linux gcc build for simple C programs

I want to build programs in the inbuilt build command of sublime text 2

I've made a gcc.sublime-build file with

{
"cmd" : ["gcc", "$file_name", "-o", "${file_base_name}"],
"selector" : "source.c",
"shell":true,
"working_dir" : "$file_path"
}

but all i get is an error saying

gcc: fatal error: no input files compilation terminated. [Finished in 0.0s with exit code 4]

any ideas

like image 664
DickWthomas Avatar asked Jul 06 '12 22:07

DickWthomas


People also ask

Can you compile C in sublime?

You can build/compile in Sublime Editor, but you can't run it on Sublime Editor. You can run it through terminal. Here is how we can do it. Open Sublime Editor, write a program and save it with .


1 Answers

Sublime Text is executing gcc without parameters because "shell": true means that the value of "cmd" is passed to a shell, and it should be one string. In your file it appears that you want to pass parameters directly to GCC, so you should set "shell" to false.

like image 97
Pkkm Avatar answered Sep 29 '22 06:09

Pkkm