Ubuntu16.04下配置最新Vs Code的C/C++开发环境

1. Vscode安装

Visual studio code是微软发布的一个运行于 Mac OS X、Windows和 Linux 之上的,针对于编写现代 Web 和云应用的跨平台源代码编辑器。
安装方式是从VScode官网下载.deb文件,然后双击该文件会打开软件中心进行安装。
在这里插入图片描述
安装完毕后即可打开VScode,主界面如下:
在这里插入图片描述
2. Vscode环境配置
(1)安装c/c++插件
首先通过左边栏的Extension栏目安装C++插件,操作如下图:
在这里插入图片描述
(2) 建立工程
由于VScode是以文件夹的形式管理工程的,因此我们首先新建一个文件夹,我这里取名叫cpp_ws.
在这里插入图片描述
然后通过VScode打开此文件夹:
在这里插入图片描述
在cpp_ws文件目录下新建cpp_primier1.cpp文件并输入下图中的程序:
在这里插入图片描述
(3) 更改配置文件(launch.json)
点击左侧的Debug按钮,选择添加配置(Add configuration),然后选择C+(GDB/LLDB),将自动生成launch.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": "enter program name, for example ${workspaceFolder}/a.out",
            "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
                }
            ]
        }
    ]
}

(4) 添加构建(编译、链接等)任务(tasks.json)
首先,利用快捷键ctrl+shift+p打开命令行,输入Tasks: Run task,然后点击:Tasks: Configure Task,然后生成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","${file}","-std=c++11","-o","${fileBasenameNoExtension}.out"]
        }
    ]
}

接下来即可通过F5来编译运行代码了。

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
要在Ubuntu 16.04中安装Visual Studio Code,你可以按照以下步骤进行操作: 1. 打开终端(使用快捷键 Ctrl + Alt + T)。 2. 添加Ubuntu桌面团队的Ubuntu Make PPA存储库。使用以下命令添加存储库: ``` sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make ``` 3. 更新软件包列表: ``` sudo apt update ``` 4. 安装Ubuntu Make: ``` sudo apt install ubuntu-make ``` 5. 使用以下命令安装Visual Studio Code: ``` umake ide visual-studio-code ``` 6. 等待安装完成后,你就可以在应用程序菜单中找到Visual Studio Code并启动它。 请注意,如果你已经安装了旧版本的Visual Studio Code,你可以使用以下命令卸载它: ``` sudo apt remove vscode ``` 希望这可以帮助你在Ubuntu 16.04中成功安装Visual Studio Code。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [ubuntu16.04安装vscode](https://blog.csdn.net/qq_40467692/article/details/121888838)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [如何在ubuntu16.04安装VSCode(超详细)](https://blog.csdn.net/xtark_robot/article/details/106662062)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yhwang-hub

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值