我曾尝试使用Mingw-w64在vscode中为c ++设置编译器,但在尝试运行简单的helloworld代码时总是会出错。
我已经重试了所有步骤,但没有看到其他结果,我认为问题是g ++的路径,但是我不知道应该使用哪个路径。
属性json:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\mingw-w64\\mingw64\\bin\\g++.exe",
"cStandard": "c11",
"cppStandard": "c++20",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
任务json:
{
"version": "2.0.0",
"tasks": [
{
"label": "test",
"type": "shell",
"command": "g++",
"args": ["-g", "-o", "test", "test.cpp"],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
我希望不会发生任何错误消息,但是会显示此错误:
"g++ : The term 'g++' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1
+ g++ -g -o test test.cpp
+ ~~~
+ CategoryInfo : ObjectNotFound: (g++:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException"