filip
filip

Reputation: 3646

Sublime does not build C++ and shows no output

I have configured a build system for C and C++ code with the following configuration file stored as C++.sublime-build.

{
    "cmd": ["gcc.exe", "-static", "-o", "$file_base_name", "$file"],
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "$file_path",
    "selector": "source.c, source.c++",
    "shell": true
}

When I build a simple C file from Sublime, in the status bar "Building" appears for some 3 seconds and the output panel opens but remains empty. "Building" finally disappears in the status bar, but no .exe file is created. My system PATH settings are correct.

When I run the same command manually from the command line, it works like a charm:

gcc -static -o test test.c

test.exe is created immediately. What is wrong with my Build System configuration?

Upvotes: 0

Views: 1036

Answers (1)

kittykitty
kittykitty

Reputation: 71

In the "cmd" line, you may try using gcc instead of gcc.exe. The following is my build system on windows, works fine.

{
    "cmd": ["gcc","-Wall", "-Wextra", "-std=c99", "${file}"],   
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c",

    "variants":
    [
        {
            "name": "Run",
            "cmd": ["bash", "-c", "gcc -Wall -Wextra -std=c99 '${file}' & '${file_path}/a'"]
        },

        {
            "name": "Run < txt",
            "cmd": ["bash", "-c", "gcc -Wall -Wextra -std=c99 '${file}' & '${file_path}/a' < '${file_base_name}'.txt"]
        },

        {
            "name": "Run 4 Macro",
            "cmd": ["bash", "-c", "gcc -E '${file}'"]
        }
    ]
}

Upvotes: 1

Related Questions