Ubuntu18.04 VSCode 环境配置

编译C/C++语言

  • 首先准备好gcc、g++、VSCode
  • 1.安装插件
    • 点击左下方图标进入拓展程序商店,在搜索框中搜索C/C++,安装C/C++插件
    • 再安装简易编译插件
  • 2.更改配置文件
    • 创建launch.json
    • 创建tasks.json

首先准备好gcc、g++、VSCode

1.安装插件

点击左下方图标进入拓展程序商店,在搜索框中搜索C/C++,安装C/C++插件

Ubuntu18.04 VSCode 环境配置_第1张图片

再安装简易编译插件

Ubuntu18.04 VSCode 环境配置_第2张图片
看到vscode在最左边第四个好像虫子的图标,这个就是调试的,点一下,然后看到最上面有个齿轮那里,点一下出来一个面板,选择刚刚装好的c++插件

2.更改配置文件

创建launch.json

{
     
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        
        {
     
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "preLaunchTask": "build",
            "setupCommands": [
                {
     
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

创建tasks.json

{
     
	"version": "2.0.0",
	"tasks": [
		{
     
			"type": "shell",
			"label": "build",
			"command": "g++",
			"args": [
				"-g",
				"${file}",
				"-o",
				"${fileDirname}/${fileBasenameNoExtension}.out"
			],
			"options": {
     
				"cwd": "/usr/bin"
			},
			"problemMatcher": [
				"$gcc"
			],
			"group": {
     
				"kind": "build",
				"isDefault": true
			}
		}
	]
}

以上配置结束后,可以直接按F5运行

你可能感兴趣的:(环境配置)