Ubuntu系统 vscode配置C++

1. vscode下载

去vscode官网下载.deb版本的
vscode官网

随后cd到对应的目录(下载文件的目录),然后

sudo dpkg -i code_1.31.1-1549938243_amd64.deb

dpkg对应的文件

具体的可以看这个链接

2.下载对应的插件

在这里插入图片描述

创建文件夹

  • 新建空文件夹
  • 用vscode打开对应文件夹并创建测试cpp文件
  • 在这里插入图片描述
在.vscode文件夹里面创建launch.json 和 task.json

具体链接

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": "${workspaceFolder}/${fileBasenameNoExtension}.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "preLaunchTask": "build",
            "setupCommands": [
                {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
                }
            ]
        }
    ]
}

task.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", "${file}", "-std=c++11", "-o", "${fileBasenameNoExtension}.out"]
        }
    ]
}
修改settings.json

按crtl + shift + p ,选择首选项:打开设置(json)
在这里插入图片描述

查询你自己的g++库在哪里

查看g++的includePath,并去Settings,json去修改。

g++ -v -E -x c++ -

修改对应的位置
在这里插入图片描述

修改cpp执行命令

在这里插入图片描述将把g++后面的filename 改为 &*.cpp 这样的话才能执行文件中的所有cpp文件,避免出现多个文件无法编译情况。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值