在新电脑上安装vscode运行带有中文路径和中文名称的C++代码时遇到报错
根据别人的教程将laugh.json
文件中"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
改成了"program": "${fileDirname}\\output\\test.exe",
,意思就是将exe
文件统一输出到output
文件夹下。
\\ laugh.json
{
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\output\\test.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "D:\\cppsoft\\mingw64\\bin\\gdb.exe",//改成mingw64安装的路径
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "task g++"
}
]
}
还有task.json
文件中的"${fileDirname}\\${fileBasenameNoExtension}.exe"
同样改成"${fileDirname}\\output\\test.exe",
,但还是报相同的错误
\\ task.json
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe 生成活动文件",
"command": "D:\\cppsoft\\mingw64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\output\\test.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}
网上教程都试过了,还是不行,后面看了下旧电脑上的扩展,发现有个.code runner
的扩展没有安装,试了下安装后居然可以运行了!!