C++:工具VSCode的编译和调试文件内容:

ubuntu24.04, vscode 配置文件 C++ 的环境

下载的gcc,使用命令为

cpp 复制代码
sudo aptitude update
sudo aptitude install build-essential -f


- `sudo`: 以超级用户权限运行命令。
- `aptitude`: 包管理工具,用于安装、更新和删除软件包。
- `install`: 安装指定的软件包。
- `build-essential`: 一个包含编译软件所需基本工具的元包,包括 `gcc`、`g++`、`make` 等。
- `-f`: 尝试修复系统中存在的依赖关系问题。
note:这里在学习C++的GUI一块时,需要下载FTLK,但一直不能顺利下载成功,原因是我下载了gcc相关的package产生冲突,所以重装系统后使用了这种统一的命令安装。

默认下载在文件/usr/bin/g++

编译文件

task.json

cpp 复制代码
{   //https://code.visualstudio.com/docs/cpp/config-linux
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: gcc build active file",
            "command": "/usr/bin/g++",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "Task generated by Debugger."
        }
    ]
}

调试文件

launch.json

cpp 复制代码
{
    // 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) Attach",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        },
   
    
    ],

    
    
}
相关推荐
-To be number.wan7 小时前
C++ 赋值运算符重载:深拷贝 vs 浅拷贝的生死线!
前端·c++
XXYBMOOO9 小时前
内核驱动开发与用户级驱动开发:深度对比与应用场景解析
linux·c++·驱动开发·嵌入式硬件·fpga开发·硬件工程
SoveTingღ12 小时前
【问题解析】我的客户端与服务器交互无响应了?
服务器·c++·qt·tcp
ygqygq213 小时前
让 AI 编程助手更智能:Turbo AI Rules 扩展使用指南
vscode·ai·扩展·rules
温宇飞13 小时前
内存异常
c++
挖矿大亨15 小时前
C++中深拷贝与浅拷贝的原理
开发语言·c++·算法
Bruce_kaizy15 小时前
c++图论——生成树之Kruskal&Prim算法
c++·算法·图论
雾岛听蓝16 小时前
C++:模拟实现string类
开发语言·c++
XFF不秃头16 小时前
力扣刷题笔记-合并区间
c++·笔记·算法·leetcode
编程之路,妙趣横生16 小时前
STL(七) unordered_set 与 unordered_map 基本用法 + 模拟实现
c++