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": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}",
// "args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"preLaunchTask": "build",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "g++",
"args": [
"-g",
"${file}",
"-L",
"/usr/local/lib/lib*",
"-std=c++11",
"-lpthread", // 多线程
"-o",
"${fileBasenameNoExtension}",
]
// "args": ["-g", "${file}"]
// g++ first.cpp -o first `pkg-config --libs --cflags opencv` -ldl
// "args": ["-g", "${file}", "-std=c++11", "-o", "${fileBasenameNoExtension}.out"]
}
]
}
本文详细介绍了如何在VSCode中设置launch.json和tasks.json文件进行C++项目的调试,包括使用gdb作为调试器,配置预构建任务以及启用pretty-printing等功能。
7万+

被折叠的 条评论
为什么被折叠?



