【发布时间】:2022-08-18 11:11:04
【问题描述】:
我在 Stack Overflow 上尝试过大多数事情,包括弄乱外部控制台值、使用以前版本的 C/C++ 扩展、将 cppbuild 更改为 shell 等。似乎没有什么能使它工作。如果我仍然按调试,我会收到一条错误消息,指出启动程序 \'....launch.exe\' 不存在。
这是我的launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
\"version\": \"0.2.0\",
\"configurations\": [
{
\"name\": \"g++.exe - Build and debug active file\",
\"type\": \"cppdbg\",
\"request\": \"launch\",
\"program\": \"${fileDirname}\\\\${fileBasenameNoExtension}.exe\",
\"args\": [],
\"stopAtEntry\": false,
\"cwd\": \"C:\\\\msys64\\\\mingw64\\\\bin\",
\"environment\": [],
\"externalConsole\": false,
\"MIMode\": \"gdb\",
\"setupCommands\": [
{
\"description\": \"Enable pretty-printing for gdb\",
\"text\": \"-enable-pretty-printing\",
\"ignoreFailures\": true
}
],
\"preLaunchTask\": \"C/C++: g++.exe build active file\",
\"miDebuggerPath\": \"C:\\\\msys64\\\\mingw64\\\\bin\\\\gdb.exe\"
}
]
}
这是我的task.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
\"version\": \"2.0.0\",
\"tasks\": [
{
\"type\": \"shell\",
\"label\": \"C/C++: gcc.exe build active file\",
\"command\": \"C:\\\\msys64\\\\mingw64\\\\bin\\\\gcc.exe\",
\"args\": [
\"-fdiagnostics-color=always\",
\"-g\",
\"${file}\",
\"-o\",
\"${fileDirname}\\\\${fileBasenameNoExtension}.exe\"
],
\"options\": {
\"cwd\": \"${workspaceFolder}\"
},
\"problemMatcher\": [
\"$gcc\"
],
\"group\": {
\"kind\": \"build\",
\"isDefault\": true
},
\"detail\": \"compiler: C:\\\\msys64\\\\mingw64\\\\bin\\\\gcc.exe\"
},
{
\"label\": \"run make\",
\"type\": \"shell\",
\"command\": \"make\"
},
{
\"label\": \"run make test\",
\"type\": \"shell\",
\"command\": \"make test\"
}
]
}
-
在您的第一个 json 文件中,您有
C/C++: g++.exe build active file,而在您的第二个文件中,您有C/C++: gcc.exe build active file。 -
您是在尝试编译 c 还是 c++?请不要同时标记两者。如果 c++ 你需要使用 g++ 而不是 gcc
-
您可以将launch.json
preLaunchTask和tasks.jsonlabel设置为更易于阅读或检查的内容,例如build-app或build-debug。
标签: c visual-studio-code gcc gdb