linux环境VSCode安装与配置

本文介绍了如何便捷安装VsCode,并通过终端使用一键安装命令。接着详细阐述了VsCode的C++配置步骤,包括安装中文和C++扩展包,创建并编辑helloworld.cpp,以及设置launch.json和tasks.json文件以实现调试功能。
摘要由CSDN通过智能技术生成

一 VsCode安装

看了很多,小鱼的安装最方便快捷

wget http://fishros.com/install -O fishros && . fishros

终端输入后,一键安装VsCode开发工具 

二 VsCode配置

1.扩展包

扩展功能按钮内分别输入“chinese”和“c++”安装中文扩展包和c++扩展包,参考下图:

2.写下第一个“hello world”

1/4 新建一个helloworld.cpp,在文件内写入以下代码:

#include <iostream>
using namespace std;

int main(int argc, char **argv)

{
  cout << "hello world!" << endl;
  return 0;

}

2/4 新建一个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",
            "miDebuggerArgs": "-q -ex quit; wait() { fg >/dev/null; }; /usr/bin/gdb -q --interpreter=mi",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

3/4 新建一个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"]
        }
     ]
}

 4/4 最后点击cpp文件,开始运行调试,你第一个在VsCod环境下的helloworld程序生成啦!!

  • 2
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值