使用Windows 10并尝试设置vs代码,我使用mingw32-gcc-g ++-bin软件包安装了MinGW。修改了Windows路径,添加了行“; C:\ MinGW \ bin”,mi json文件如下所示:
{
"name": "Win32",
"includePath": [
"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/include/*",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/um",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/ucrt",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/shared",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/winrt",
"C:/MinGW/bin",
"${workspaceRoot}",
"${workspaceFolder}"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"compilerPath": "C:/MinGW/bin/g++",
"intelliSenseMode": "msvc-x64",
"browse": {
"path": [
"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/include/*",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/um",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/ucrt",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/shared",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/winrt",
"C:/MinGW/bin",
"${workspaceRoot}",
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
我也尝试从cmd终端调用g ++,但是它仍然失败,因为“ g ++无法识别为内部或外部命令...”
答案 0 :(得分:0)
“无法将g ++识别为内部或外部命令”表示在PATH中找不到g ++。程序未正确安装,或者PATH设置不正确。
首先检查g ++确实在PATH中。打开一个新的终端并编写g ++。如果出现错误消息,请执行
cd C:\MinGW\bin
g++
。 Windows不仅在PATH变量中搜索,还在当前目录中搜索。如果错误消息仍然存在,则无法在此处找到g ++(您可以在文件浏览器中看到g ++。exe的当前路径吗?)。如果错误消息消失并且应用程序启动(但抱怨缺少参数),则路径设置不正确。通过做检查路径变量
echo %PATH%
,并验证是否缺少C:\ MinGW \ bin。首先将其添加到本地,然后尝试从另一个目录执行g ++: 设置PATH =%PATH%; C:\ MinGW \ bin 光盘.. g ++ 我们现在正在从父文件夹中调用g ++,该文件夹现在应该可以正常工作,因为现在可以在PATH中成功找到g ++。但是请注意,这是本地PATH,只能在当前命令提示符下找到。
将g ++添加到用户或全局路径:https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/
在链接中添加变量后,重新启动终端并尝试再次执行g ++,但这一次成功。重新启动Visual Studio Code以重新加载路径变量,该程序也应该能够找到g ++。