“vs code“ No such file or directory gcc

1 . 在配置VS CODE开发环境的时候一直无法导入#include ,一直是红线。
2. 在网上找了资料,将如下的配置都安排好之后还出了错
3. 结果是因为g++.exe的程序选错了,应该选x86_64-w64-mingw32-g++

具体操作如下

1.先按Ctri+shift+p,找到C/C++ Configurations,然后将编译器路径改为如下所示,就可以了
在这里插入图片描述

这里是我的配置

我已经在扩展里面安装了C/C++ 扩展

在这里插入图片描述
这是我的c_cpp_preperties.json配置

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-x64",
            "compilerPath": "E:\\mingw64\\bin\\x86_64-w64-mingw32-g++.exe"
        }
    ],
    "version": 4
}

lauch.json

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
                         "name": "g++.exe build and debug active file",
                         "type": "cppdbg",
                         "request": "launch",
                         "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
                         "args": [],
                         "stopAtEntry": false,
                         "cwd": "${workspaceFolder}",
                         "environment": [],
                         "externalConsole": true,      //修改此项,让其弹出终端
                         "MIMode": "gdb",
                         "miDebuggerPath": "E:\\mingw64\\bin\\gdb.exe",
                         "setupCommands": [
                            {
                                "description": "Enable pretty-printing for gdb",
                                "text": "-enable-pretty-printing",
                                "ignoreFailures": true
                            }
                        ],
                        "preLaunchTask": "C/C++: g++.exe 生成活动文件" //修改此项
                   }

    ]
}

task.json配置

{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "cppbuild",
			"label": "C/C++: g++.exe 生成活动文件",
			"command": "E:\\mingw64\\bin\\g++.exe",
			"args": [
				"-fdiagnostics-color=always",
				"-g",
				"${file}",
				"-o",
				"${fileDirname}\\${fileBasenameNoExtension}.exe"
			],
			"options": {
				"cwd": "E:\\mingw64\\bin"
			},
			"problemMatcher": [
				"$gcc"
			],
			"group": {
				"kind": "build",
				"isDefault": true
			},
			"detail": "编译器: E:\\mingw64\\bin\\g++.exe"
		},
		{
			"type": "cppbuild",
			"label": "C/C++: g++.exe 生成活动文件",
			"command": "E:\\mingw64\\bin\\g++.exe",
			"args": [
				"-fdiagnostics-color=always",
				"-g",
				"${file}",
				"-o",
				"${fileDirname}\\${fileBasenameNoExtension}.exe"
			],
			"options": {
				"cwd": "E:\\mingw64\\bin"
			},
			"problemMatcher": [
				"$gcc"
			],
			"group": "build",
			"detail": "编译器: E:\\mingw64\\bin\\g++.exe"
		}
	]
}
  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值