Question

i am using Windows 7 and I have added

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

to my c.sublime-build and although it can build my program, the run option disappears. So I can not see the output of my simple hello world program.

No correct solution

OTHER TIPS

You need to add a variant for the Run option that will execute the program. Here's what my g++.sublime-build looks like

{
    "shell_cmd": "g++ \"${file}\" -O3 -std=c++11 -pedantic -Wall -Wextra -Wconversion -o \"${file_path}/${file_base_name}\"",
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c, source.c++",

    "variants":
    [
        {
            "name": "Run",
            "shell_cmd": "g++ \"${file}\" -O3 -std=c++11 -pedantic -Wall -Wextra -Wconversion -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""
        }
    ]
}

My Run option builds and then runs the program, get rid of the first half of the command if you only want it to run the executable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top