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
                }
            ]
        },
   
    
    ],

    
    
}
相关推荐
2401_839080549 分钟前
C++常见八股
数据结构·c++·算法
qq_1998868727 分钟前
第6板块 第2节 CUDA运行时API与驱动API 核心笔记
c++·人工智能·gpu算力
syagain_zsx1 小时前
算法基础篇 · 03 枚举(C++ 题解)
c++·算法·二进制·枚举
weixin_307779132 小时前
C++代码实现MATLAB中的ode23tb函数功能
开发语言·c++·算法·matlab
S_WEAN2 小时前
C++STL - string类的模拟实现
c++
S_WEAN2 小时前
【C++】STL - string类
c++
码匠许师傅3 小时前
【C++三方组件】toml++:人性化的配置文件格式
c++
__pop_4 小时前
VSCode Remote SSH 远程连接 glibc 高版本依赖问题
vscode
骑着蜗牛撵大象3274 小时前
告别内存泄漏:LLMManager架构设计与智能指针在AI SDK中的智慧选型
c++·ai·架构