我是一个C编程新手。我遇到了错误:(preLaunchTask 'C/C++:gcc.exe build active file'以退出代码-1终止)当我调试时,如下所示:
我的launch.json是:
"version": "0.2.0",
"configurations": [
{
"name": "gcc.exe - 生成和调试活动文件",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe build active file"
}
]
}
我的tasks.json是:
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe build active file",
"command": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\gcc.exe",
"args": [
"-g",
"${workspaceFolder}\\*.c",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: \"C:\\Program Files\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\gcc.exe\""
}
]
}
2条答案
按热度按时间lztngnrs1#
“程序”:“${fileDirname}${fileBasenameNoExtension}.exe”,
1.您需要在
{fileDirname}
中给予包含文件的目录名1.您需要在
{fileBasenameNoExtension}
中给予可执行文件的名称ubof19bj2#
看起来你是从中国来的。请检查:
1.如果有空格或其他可能影响编译的字符。在我的例子中,我的文件夹包含一个“&”,当我查找为我生成的命令VSCode时,该命令不包含“&”之后的所有内容,并且无法找到正确的可执行文件。
这是一个很好的做法,使您的文件夹名称干净。希望这有帮助!