无法在 Visual Studio 代码中生成和运行 C++ 代码

Unable to build and run c++ code in visual studio code

本文关键字:代码 运行 C++ Visual Studio      更新时间:2023-10-16

我已经为 mingw 设置了正确的路径,并且能够成功地使用 vscode 中的终端编译我的代码。但是当我按ctrl+shift+b进行构建时,我的终端中出现以下错误

Executing task: C:MinGWbing++.exe -g 'c:UsersAnsh KapoorDesktopcppmain.cpp' -o 'c:UsersAnsh 
KapoorDesktopcppmain.exe'<
/usr/bin/bash: C:MinGWbing++.exe: command not found
The terminal process terminated with exit code: 127

而当我编写时,相同的代码已成功执行

g++ main.cpp -o 'main.exe'

现在我已经检查了路径和环境变量,所有这些事情都是正确的。

找到正确路径的错误是因为使用 git bash 作为终端而不是 windows powershell 或 cmd。