我试图在VS Code中编译c ++。 我安装了MinGW。 我已按照此视频中的步骤操作:https://www.youtube.com/watch?v=rFdJ68WbkdQ
"开始的步骤" docs https://code.visualstudio.com/docs/languages/cpp
实际上,我的配置显示如下:
{
"configurations": [
{
"name": "Mac",
"includePath": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"defines": [],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"macFrameworkPath": [
"/System/Library/Frameworks",
"/Library/Frameworks"
]
},
{
"name": "Linux",
"includePath": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"defines": [],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
},
{
"name": "Win32",
"includePath": [
"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/include/*",
"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/atlmfc/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",
"${workspaceRoot}"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"intelliSenseMode": "msvc-x64",
"browse": {
"path": [
"${workspaceRoot}",
"C:\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++",
"C:\\MinGW\\bin"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 3
}
" tasks.json"文件包含以下内容:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "g++",
"args": [
"-g", "Calculator.cpp", "-o","Calculator"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher":"$gcc"
}
]
}
但是当我点击"运行主要任务"它提示:
">执行任务:g ++ -g Calculator.cpp -o Calculator<
'克++'不被视为内部或外部命令, 可操作程序或批处理文件。 终端进程以退出代码终止:1"
如何检测gcc?
我在Windows 10机器BTW上使用VS Code。
答案 0 :(得分:1)
如果您尚未将文件夹路径添加到Windows,请先尝试。
如果仍然无效,请尝试在" task.json"中添加完整路径。而不只是g ++。
这样的事情: C:/ MinGW的/ bin中/克++