ctrl+shift+p打开搜索框, ctrl+`打开控制台,F9打断点,F5 Debug
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", //任务名,和lanuch.json中的"preLaunchTask":"build"一致
"type": "shell",
"command": "g++",
"args": [
"-g",
"${workspaceRoot}/${fileBasenameNoExtension}.cpp",
"-o",
"${fileBasenameNoExtension}.out",
], //要编译的文件mian_test.cpp,${workspaceRoot}表示vscode所打开的工作目录
"problemMatcher": {
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"pattern": {
"regexp": "^([^\\\\s].*)\\\\((\\\\d+,\\\\d+)\\\\):\\\\s*(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"location": 2,
"message": 5
}
}
}
]
}
launch.json的配置:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/${fileBasenameNoExtension}.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build"
}
]
}
opencv配置(c_cpp_properties.json):
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include",
"/home/nowburn/app/opencv/opencv3.4.7/include" //自定义安装opencv的路径
],
"defines": [],
"compilerPath": "/usr/bin/g++",
"cStandard": "c11",
"cppStandard": "c++11",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}