栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

VS Code C++ 开发调试环境配置

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

VS Code C++ 开发调试环境配置

VS Code 项目的配置文件位于.vscode文件夹下。本文将具体说明在vscode中如何操作生成.vscode 文件夹下的三个配置文件:

(1). tasks.json (compiler build settings) ,负责编译

(2). launch.json (debugger settings),负责调试

(3). c_cpp_properties.json (compiler path and IntelliSense settings),负责更改路径等设置

首先安装C++拓展。点击在vscode界面最左侧的Extensions图标(打开快捷键:ctrl+shift+X),搜索“C/C++”,点击进行安装。

1、创建 tasks.json

告诉 VS Code 如何构建(编译)程序

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++ build active file",
            "command": "/usr/bin/g++",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "compiler: /usr/bin/g++"
        }
    ]
}
2、创建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": "g++ - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++ build active file",
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}
3、创建c_cpp_properties.json

更多地控制 C/C++ 扩展,它允许你更改设置,例如编译器的路径、包含路径、C++ 标准(默认为 C++17)

{
  "configurations": [
    {
      "name": "Linux",
      "includePath": ["${workspaceFolder}/**"],
      "defines": [],
      "compilerPath": "/usr/bin/gcc",
      "cStandard": "c11",
      "cppStandard": "c++17",
      "intelliSenseMode": "clang-x64"
    }
  ],
  "version": 4
}
4、settings.json

对vscode的一些定制化内容

vscode的setting.json的配置 - 简书

针对Apollo的开发调试(待补充) 远程调试:

        ssh:vscode通过ssh远程访问,或登入docker容器均无障碍

详解Linux下使用vscode编译运行和调试C/C++ - 知乎

Ubuntu上vscode编译C++_Xu小亿的博客-CSDN博客_ubuntu vscode 编译

使用 vscode-insiders 的docker扩展 调试Apollo项目_Rancho2018的博客-CSDN博客_vscode-insiders

使用Visual Studio Code编译、调试Apollo项目_知行合一2018的博客-CSDN博客_apollo vscode

自动驾驶开发者说|框架|如何用vscode调试apollo? - 知乎

VS Code调试问题记录_WangN2的博客-CSDN博客

复杂环境变量的VSCode调试方法_WangN2的博客-CSDN博客

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/830093.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号