使用vscode写c语言代码时发现无法编译运行,在此之前对配置文件未进行过修改,且前一天程序能够正常运行
目前helloworld在vscode上也无法运行成功,报错均为
终端进程“C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command D:\x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0\mingw64\bin\g++.exe -g 'd:\Microsoft VS Code\VS_CODE\ADS\PJ1\AVL_Tree.cpp' 'd:\Microsoft VS Code\VS_CODE\ADS\PJ1\AVL.cpp' -o 'd:\Microsoft VS Code\VS_CODE\ADS\PJ1\AVL_Tree.exe' -I 'D:\Microsoft VS Code\VS_CODE' -std=c++17”已终止,退出代码: 1。
相同的代码在dev c++上能够正常运行
附终端报错代码、配置文件代码
终端报错:
Executing task: D:\x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0\mingw64\bin\g++.exe -g 'd:\Microsoft VS Code\VS_CODE\ADS\PJ1\AVL_Tree.cpp' 'd:\Microsoft VS Code\VS_CODE\ADS\PJ1\AVL.cpp' -o 'd:\Microsoft VS Code\VS_CODE\ADS\PJ1\AVL_Tree.exe' -I 'D:\Microsoft VS Code\VS_CODE' -std=c++17 <
终端进程“C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command D:\x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0\mingw64\bin\g++.exe -g 'd:\Microsoft VS Code\VS_CODE\ADS\PJ1\AVL_Tree.cpp' 'd:\Microsoft VS Code\VS_CODE\ADS\PJ1\AVL.cpp' -o 'd:\Microsoft VS Code\VS_CODE\ADS\PJ1\AVL_Tree.exe' -I 'D:\Microsoft VS Code\VS_CODE' -std=c++17”已终止,退出代码: 1。
配置文件:
launch.json
{
"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": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "D:\\x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0\\mingw64\\bin\\gdb.exe", /*修改成自己bin目录下的gdb.exe,这里的路径和电脑里复制的文件目录有一点不一样,这里是两个反斜杠\\*/
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "task g++"
}
]
}
tasks.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": "task g++",
"command": "D:\\x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0\\mingw64\\bin\\g++.exe", /*修改成自己bin目录下的g++.exe,这里的路径和电脑里复制的文件目录有一点不一样,这里是两个反斜杠\\*/
"args": [
"-g",
"${file}",
//"${fileDirname}\\Lab_2_Stash.cpp", // 多个文件编译
//"${fileDirname}\\AVL.cpp",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"-I",
"D:\\Microsoft VS Code\\VS_CODE", /*修改成自己放c/c++项目的文件夹,这里的路径和电脑里复制的文件目录有一点不一样,这里是两个反斜杠\\*/
"-std=c++17"
],
"options": {
"cwd": "D:\\x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0\\mingw64\\bin" /*修改成自己bin目录,这里的路径和电脑里复制的文件目录有一点不一样,这里是两个反斜杠\\*/
},
"problemMatcher":[
"$gcc"
],
"group": "build",
}
]
}
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": ["${workspaceFolder}/**"],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.17763.0",
"compilerPath": "D:\\x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0\\mingw64\\bin\\g++.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "${default}"
}
],
"version": 4
}