How to compile and run C program using Sublime Text on Ubuntu 12.04?

Asked

Viewed 2,508 times

1

You can configure Sublime Text 2 so that it will embed a C code and then run and show the result in the terminal?

  • Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?

1 answer

1

Yes, it is possible to configure the build of it. I imagine you already know the documentation. What you probably lack is how to create a configuration file on Linux. It probably works:

{
    "linux":
    {
        "cmd": ["cc","-std=c99" ,"$file_name","-o", "${file_base_name}", "-lm", "-Wall", ";", "./${file_base_name}"]
    },
    "selector" : "source.c",
    "shell": true,
    "working_dir" : "$file_path",
}

Taken from that response in the OS.

This may have to be adapted depending on how your installation is.

  • I started wearing the Sublime recently and had already seen this build, but it didn’t work here. Presents this error: "Error trying to parse build system: Trailing comma before closing Bracket in ~/. config/sublime-text-2/Packages/User/test.sublime-build:9:1"

  • I also never used but there are several people using this setting.

  • I was able to correct the error that was giving but the result was shown inside the Sublime itself, I wanted to print in the terminal. Is there no way?

  • As far as I’ve seen there’s no way, but I can’t guarantee it. In the answer itself I Linkei talks about this.

  • At least in Python it is possible, according to this site: http://pythoneiro.blogspot.com.br/2014/10/sublime-text-3-executando-script-no.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.