【问题标题】:Sublime Text 3 C++ build systemSublime Text 3 C++ 构建系统
【发布时间】:2013-10-14 05:56:21
【问题描述】:

您好,我在 Sublime Text 3 中的 C++ 构建系统有点混乱,现在我无法运行任何程序。 这是我的构建系统:

{
  "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": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" && open -a Terminal -e \"${file_path}/${file_base_name}\""
    }
  ]
}

感谢您的帮助, 尼诺

【问题讨论】:

  • 您的问题是什么?您面临的问题是什么?
  • 你为什么要转义所有的引号?

标签: c++ macos terminal sublimetext3


【解决方案1】:

唯一错误的想法似乎是您编写command 的方式。新文档中没有说明,但是在old one你可以阅读

命令: 数组 包含要运行的命令及其所需的参数。

所以,这个构建系统应该可以解决问题(这是默认提供的):

{
    "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}'"]
        }
    ]
}

请注意,之前有人报告说默认提供的C++.sublime-build 存在问题(在我的 OS X 上一切正常)。如果是这种情况,请考虑 salek 在this answer 上的回复。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-10-21
    • 2015-03-01
    • 2020-10-07
    • 2018-04-27
    • 2015-02-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多