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

    
    
}
相关推荐
小刘同学3211 小时前
C++11 特性
c++·c11新特性
真的想上岸啊1 小时前
学习C++、QT---18(C++ 记事本项目的stylesheet)
开发语言·c++·学习
m0_552200822 小时前
《UE5_C++多人TPS完整教程》学习笔记40 ——《P41 装备(武器)姿势(Equipped Pose)》
c++·游戏·ue5
youngqqcn2 小时前
VSCode-Copilot的系统提示词
ide·vscode·copilot
GBXLUO2 小时前
windows的vscode无法通过ssh连接ubuntu的解决办法
vscode·ubuntu
丁劲犇2 小时前
用 Turbo Vision 2 为 Qt 6 控制台应用创建 TUI 字符 MainFrame
开发语言·c++·qt·tui·字符界面·curse
charlie1145141913 小时前
深入理解Qt的SetWindowsFlags函数
开发语言·c++·qt·原理分析
呜喵王阿尔萨斯3 小时前
编程中的英语
c语言·c++
whoarethenext4 小时前
使用 C++/Faiss 加速海量 MFCC 特征的相似性搜索
开发语言·c++·faiss