0

我正在尝试通过 sublime text 2 运行 c++ 程序。我不想将 bash 添加到我的 PATH 中。
我想将默认的 cmd 命令更改为以下内容:

./${file}

我在 c++ 包文件夹中四处寻找,但只找到了构建。

我很感激一些帮助!

[编辑]
我的程序正确构建,但在运行时我得到这个:

[Error 2] The system cannot find the file specified
[cmd:  [u'bash', u'-c', u"g++ 'C:...]
[dir:  C:\Users\...]
[path: C:/.../
[Finished]

[编辑] 根据要求,我的构建文件。

{
    "cmd": ["g++", "${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++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
        }
    ]
}
4

1 回答 1

0
{
    "cmd": ["g++", "${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": ["${file_path}/${file_base_name}"]
        }
    ]
}

Just drop the compilation command and retain only the executable invocation part. But remember, you have to compile before running otherwise the executable would not have got generated.

于 2013-08-20T01:06:15.617 回答