当我尝试编译我的 C++ 代码时,Sublime Text 3 在状态栏上显示 "No Build System"。为什么?
Sublime Text 3 shows "No Build System" on the status bar when I try to compile my C++ code. Why?
当我尝试构建它时显示此错误。只有在我在自定义构建系统文件中输入以下代码后才会发生这种情况:
只有在输入代码的 "Run in CMD" 部分后才会发生
{
"shell_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",
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""
}
{
"name": "Run in CMD",
"shell_cmd": "start \"$file_base_name\" call $file_base_name"
}
]
}
该程序的用途是增加一个变体,它在CMD中打开编译后的程序,而不是在Sublime Text 3中打开集成终端。
显示 No build system
消息的最终原因是当您尝试 运行 构建时,Sublime 不知道它应该应用什么构建系统。
当您将构建设置为 Automatic
但当前文件属于 Sublime 无法确定其构建系统的类型时,可能会发生这种情况,但也可能会在构建文件时发生将使用(通过 Automatic
或被明确告知)以某种方式被破坏。
你的情况就是这个原因; sublime-build
文件第 12 行的两个变体之间缺少 ,
。因此该文件无效 JSON,构建文件被视为不存在,并且您会收到有关没有构建系统的消息。
添加逗号应该可以解决您的问题:
{
"shell_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",
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""
}
// These two variants are part of a list; they need to be separated
// with a comma
{
"name": "Run in CMD",
"shell_cmd": "start \"$file_base_name\" call $file_base_name"
}
]
}
当我尝试构建它时显示此错误。只有在我在自定义构建系统文件中输入以下代码后才会发生这种情况:
只有在输入代码的 "Run in CMD" 部分后才会发生
{
"shell_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",
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""
}
{
"name": "Run in CMD",
"shell_cmd": "start \"$file_base_name\" call $file_base_name"
}
]
}
该程序的用途是增加一个变体,它在CMD中打开编译后的程序,而不是在Sublime Text 3中打开集成终端。
显示 No build system
消息的最终原因是当您尝试 运行 构建时,Sublime 不知道它应该应用什么构建系统。
当您将构建设置为 Automatic
但当前文件属于 Sublime 无法确定其构建系统的类型时,可能会发生这种情况,但也可能会在构建文件时发生将使用(通过 Automatic
或被明确告知)以某种方式被破坏。
你的情况就是这个原因; sublime-build
文件第 12 行的两个变体之间缺少 ,
。因此该文件无效 JSON,构建文件被视为不存在,并且您会收到有关没有构建系统的消息。
添加逗号应该可以解决您的问题:
{
"shell_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",
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""
}
// These two variants are part of a list; they need to be separated
// with a comma
{
"name": "Run in CMD",
"shell_cmd": "start \"$file_base_name\" call $file_base_name"
}
]
}