【发布时间】:2021-01-15 09:07:12
【问题描述】:
我在我的 Sublime Text 3 for C++ 14 中创建了一个新的构建系统,并粘贴了以下代码并将其保存为 c++ 14。
{
"cmd":["bash", "-c", "g++ -std=c++14 -Wall '${file}' -o '${file_path}/${file_base_name}' && '${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++ -std=c++14 '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
}
]
}
但是每当我选择这个构建(保存 C++ 14)来运行我的 c++ 程序时,我的 Sublime Text 就会给出以下错误:
[WinError 2] The system cannot find the file specified
[cmd: ['bash', '-c', "g++ -std=c++14 -Wall 'C:\\Users\\ragha\\Desktop\\All_Folders\\sublime_cpp\\_code.cpp' -o 'C:\\Users\\ragha\\Desktop\\All_Folders\\sublime_cpp/_code' && 'C:\\Users\\ragha\\Desktop\\All_Folders\\sublime_cpp/_code'"]]
[dir: C:\Users\ragha\Desktop\All_Folders\sublime_cpp]
[path: C:\Python38\Scripts\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Calibre2\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\Java\jdk-14.0.1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Python38\python.exe;C:\Python38;C:\MinGW\bin;C:\Users\ragha\AppData\Local\Microsoft\WindowsApps;C:\src\flutter\bin;C:\MinGW\bin;]
[Finished]
注意 - 我已经安装了 MinGW C++ 安装程序。我已将 C:/MinGw/bin 添加到 Global Variables as well as System Variables 的路径中。当我使用C++ single file build 运行我的 C++ 程序时,它运行良好。我的系统中没有任何 WSL。
如何解决问题。
请帮忙!
【问题讨论】:
-
如果你只使用
MinGW而不使用WSL,那么你可能没有bash,你也不需要它。内置构建和您的构建之间的区别主要在于。只需复制C++ Single File.sublime-build的内容并修改参数即可,不需要bash。
标签: c++ windows sublimetext3 mingw