加入收藏 | 设为首页 | 会员中心 | 我要投稿 开发网_新乡站长网 (https://www.0373zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

Linux上使用vscode编译运行和调试C/C++

发布时间:2022-12-06 10:28:32 所属栏目:Linux 来源:
导读:  tasks.json 指定编译文件

  launch.json 使用gdb调试

  ctrl+shift+p

  tasks.json

  {
   "version": "2.0.0",
   "tasks": [
   {
   "label":
  tasks.json 指定编译文件
 
  launch.json 使用gdb调试
 
  ctrl+shift+p
 
  tasks.json
 
  {
      "version": "2.0.0",
      "tasks": [
          {
              "label": "default",
              "type": "shell",
              "command": "g++",
              "args": [
                  "-g",
                  "${file}",
                  "-o",
                  "${fileDirname}/${fileBasenameNoExtension}", //importance
              ],
              "problemMatcher": {
                  "owner": "cpp",
                  "fileLocation": [
                      "relative",
                      "${workspaceRoot}"
                  ],
                  "pattern": {
                      "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                      "file": 1,
                      "line": 2,
                      "column": 3,
                      "severity": 4,
                      "message": 5
                  }
              },
              "group": {
                  "kind": "build",
                  "isDefault": true
              }
          }
      ]
  }
  launch.json
 
  {
   "version": "0.2.0",
   "configurations": [
          {
   "name": "(gdb) Launch",
   "type": "cppdbg",
   "request": "launch",
   "program": "${fileDirname}/${fileBasenameNoExtension}",//importance
   "args": [],
   "stopAtEntry": false,
   "cwd": "${workspaceFolder}",
   "environment": [],
   "externalConsole": false,
   "MIMode": "gdb",
   "preLaunchTask": "default", // must specify task name(label in tasks.json)
   "setupCommands": [
                  {
   "description": "Enable pretty-printing for gdb",
   "text": "-enable-pretty-printing",
   "ignoreFailures": true
                  }
              ]
          }
      ]
  }
 
 

(编辑:开发网_新乡站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!