Can't build C++ program using Sublime Text 2

build, c++, sublimetext, sublimetext2

Solution

Edit your C++.sublime-build file....works like a charm.

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

    "variants":
    [
        {
            "name": "Run",
            "cmd": ["bash", "-c", "g++ -Wall -Wextra -pedantic -std=c++11 '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
        }
    ]
}

Problem

I think many of you are using or used to use Sublime Text 2 editor. I have strange error: C++ programs can't be built. My `C++.sublime-build`: ``` { "cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"], "working_dir": "${file_path}", "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", "selector": "source.c, source.c++", "variants": [ { "name": "Run", "cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"] } ] } ``` I found that when the `cmd` array contains ANY substituted expression like `${file}` or `$file`, build doesn't start. Otherwise it starts. It doesn't matter from compiler. When I've tried `"cmd": ["notify-osd", "$file"]`, it didn't work; but with `"cmd": ["notify-osd", "sometexthere"]` it worked. Compiling by-hand works right. My program: ``` #include <iostream> int main() { std::cout << "Hello World"; } ``` I use Ubuntu 12.04, 32bit. Version of Sublime Editor: 2.0.1. If it isn't the place where I could ask this question, please tell me what's the right one.

Original source