VSCode配置LeetCode调试环境

目录

1. 插件

2.登录

3.node.js

4.配置


”工欲善其事必先利其器“

1. 插件

首先直接上 vscode官网 来安装vscode,打开vscode之后要安装几个插件,分别LeetCodeDebug LeetCodeC/C++,具体按照下图来搜索,再点击install进行安装,等安装完毕重启vscode即生效:

2.登录

有些用户在使用leetcode插件会出现登录不上,那是因为登陆节点没有选择国内,如下图先将登陆节点修改为leetcode-cn即可:

接着就是登陆账号,如下图所示,点击LeetCode Account进行账号登陆

登录成功后,这样就可以开始进行刷题,但是这个插件运行还需要nodejs来支持

3.node.js

# 更新系统包列表
sudo dnf update -y  # 如果你使用的是基于Red Hat的系统如CentOS或Rocky Linux
# 或者
sudo apt update  # 如果你使用的是基于Debian的系统如Ubuntu

# 使用NodeSource安装最新的LTS版本(例如,Node.js 18.x)
curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash -  # 对于RPM-based系统
# 或者
curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -  # 对于Debian-based系统

# 安装Node.js
sudo dnf install -y nodejs  # 对于RPM-based系统
# 或者
sudo apt install -y nodejs  # 对于Debian-based系统

# 验证安装
node -v
npm -v

4.配置

选择C++(GDB/LLDB)进行gdb调试:

这时vscode会跳到配置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) 启动",
            "type": "cppdbg",
            "request": "launch",										// 请求配置类型,可以为launch(启动)或attach(附加)
            "program": "输入程序名称,例如 ${workspaceFolder}/a.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,							    // 调试时是否显示控制台窗口
            "MIMode": "gdb",
            "miDebuggerPath": "D:/mySoftware/MinGW/bin/gdb.exe",       // 修改为刚安装的MinGW/bin/gdb.exe路径
            "preLaunchTask": "g++",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

点击下图橙色方框,即可 设置断点在 gdb 下调试代码啦

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值