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

    
    
}
相关推荐
悠仁さん1 小时前
【C++】AVL 树
c++
wuminyu1 小时前
JVM规范学习总结:解释器与JIT编译器如何处理JVM字节码
java·linux·c语言·jvm·c++
小徐不徐说2 小时前
序列化与反序列化:把 C++ 对象可靠地保存下来
开发语言·数据库·c++·php
ragnwang2 小时前
Notes: Python pybind11 import C++ module
开发语言·c++·python
充值内卷3 小时前
我给桌面加了个鱼缸:C++ 写后端,WebView2 里养一座 Three.js 小岛
开发语言·javascript·c++
樱花树下的数学喵6 小时前
手写简易 STL string|C++ 字符串底层实现
开发语言·c++
AI吃大瓜6 小时前
指针压力表读数3:C/C++实现指针压力表读数(可实时检测)
c++·指针读数·指针压力表·压力表自动读数·压力表读数
-银雾鸢尾-6 小时前
两数之和-C++实现
c++·算法
j7~7 小时前
【动态规划算法专题】动态规划五部曲实战:泰波那契数、三步问题、最小花费爬楼梯
c++·算法·动态规划·数据结构与算法
jimy17 小时前
C++ 报错的 qualifiers 的意思
开发语言·c++