无法使用Sublime Text 2构建C++程序

Iva*_*lov 6 c++ build sublimetext sublimetext2

我想很多人都在使用或习惯使用Sublime Text 2编辑器.我有一个奇怪的错误:无法构建C++程序.

我的 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}'"]
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

我发现当cmd数组包含任何替换表达式时,${file}或者$file,build不会启动.否则它会启动.

它与编译器无关.当我尝试时"cmd": ["notify-osd", "$file"],它没有用; 但随着"cmd": ["notify-osd", "sometexthere"]它工作.

手工编译工作正确.

我的节目:

#include <iostream>

int main() {
    std::cout << "Hello World";
}
Run Code Online (Sandbox Code Playgroud)

我使用Ubuntu 12.04,32bit.Sublime Editor的版本:2.0.1.

如果不是我可以提出这个问题的地方,请告诉我什么是正确的.

sal*_*lek 7

编辑你的C++.sublime-build文件....就像一个魅力.

{
    "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}'"]
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)