ubuntu配置vscode c++编译环境遇到的问题

1.安装vscode
2.安装c++插件
3.运行生成默认的launch和tasks文件,运行后仍然报错
ubuntu配置vscode c++编译环境遇到的问题_第1张图片
查看launch代码

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        
        {
            "name": "gcc - 生成和调试活动文件",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "gcc build active file",//注意此处task名称
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}

task代码

{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "shell",
			"label": "C/C++: gcc build active file",//此处task名称与launch不一致
			"command": "/usr/bin/gcc",
			"args": [
				"-g",
				"${file}",
				"-o",
				"${fileDirname}/${fileBasenameNoExtension}"
			],
			"options": {
				"cwd": "/usr/bin"
			},
			"problemMatcher": [
				"$gcc"
			],
			"group": "build"
		}
	]
}

两处代码task名称不一致,更改tsaks.json
“label”: “C/C++: gcc build active file”, 更改为
“label”: “gcc build active file”,
即可成功运行

你可能感兴趣的:(ubuntu配置vscode c++编译环境遇到的问题)