前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >C/C++ Development using Visual Studio Code, CMake and LLDB

C/C++ Development using Visual Studio Code, CMake and LLDB

作者头像
吕海峰
发布2018-04-03 15:41:49
1.7K0
发布2018-04-03 15:41:49
举报
文章被收录于专栏:BrianBrian

概述

由于我工作环境是Linux和Mac,个人的工作目录和开发环境一直来回切换,之前一直使用emacs。不可否认,emacs非常强大和可定制化。昨天由于个人电脑系统损坏,重装了osx。在好基友的推荐下,试用vscode,发现非常不错。于是记录和分享到博客中。今天主要给大家讲解的vscode配置c/c++ ide开发环境,当然官网支持很多种可定制化的配置。

开发环境搭建

我们首先安装vscode,官网是:vscode。我们下面来安装支持c/c++开发环境的安装包。

  • cpptools
  • cmake
  • C/C++ Clang

我们在工作目录依次安装如下,c_cpp_properties.json(指定c/c++包和平台相关的配置文件),launch.json(debug 调试),tasks.json(你的编译等命令)

c_cpp_propertie.json

{
  "configurations": [
    {
      "name": "Mac",
      "includePath": [
        "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1",
        "/usr/local/include",
        "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/include",
        "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
        "/usr/include",
        "${workspaceRoot}"
      ],
      "defines": [],
      "intelliSenseMode": "clang-x64",
      "browse": {
        "path": [
          "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1",
          "/usr/local/include",
          "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/include",
          "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
          "/usr/include",
          "${workspaceRoot}"
        ],
        "limitSymbolsToIncludedHeaders": true,
        "databaseFilename": ""
      },
      "macFrameworkPath": [
        "/System/Library/Frameworks",
        "/Library/Frameworks"
      ]
    },
    {
      "name": "Linux",
      "includePath": [
        "/usr/include",
        "/usr/local/include",
        "${workspaceRoot}"
      ],
      "defines": [],
      "intelliSenseMode": "clang-x64",
      "browse": {
        "path": [
          "/usr/include",
          "/usr/local/include",
          "${workspaceRoot}"
        ],
        "limitSymbolsToIncludedHeaders": true,
        "databaseFilename": ""
      }
    },
    {
      "name": "Win32",
      "includePath": [
        "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include",
        "${workspaceRoot}"
      ],
      "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
      ],
      "intelliSenseMode": "msvc-x64",
      "browse": {
        "path": [
          "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/*",
          "${workspaceRoot}"
        ],
        "limitSymbolsToIncludedHeaders": true,
        "databaseFilename": ""
      }
    }
  ],
  "version": 3
}

我们再看一下下面的debug下的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": "(lldb) Launch",
      "type": "cppdbg",
      "request": "launch",
      "program": "${workspaceFolder}/build/DemoProject",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${workspaceFolder}/build",
      "environment": [],
      "externalConsole": false,
      "MIMode": "lldb"
    }
  ]
}

最后一个是tasks.json

{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "echoCommand": true,
  "options": {
    "cwd": "${workspaceRoot}/build"
  },
  "tasks": [
    {
      "label": "cmake",
      "type": "shell",
      "command": "cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=Debug ..",
      "group": {
        "kind": "build",
        "isDefault": true
      }
    },
    {
      "label": "make",
      "type": "shell",
      "command": "make -j 8",
      "group": {
        "kind": "build",
        "isDefault": true
      }
    }
  ]
}

效果

整体布局
整体布局
智能提示
智能提示
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-01-14,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 概述
  • 开发环境搭建
    • c_cpp_propertie.json
    • 效果
    领券
    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档