1、加载项目文件
2、配置c_cpp_properties.json文件
vscode下的C或C++项目的配置文件是c_cpp_properties.json,用快捷键ctrl+shift+p调出vscode命令搜索框,搜索Edit Configurations并点击就会跳转到c_cpp_properties.json文件的编辑界面,将include加入到includePath即可:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/include",
"${workspaceFolder}/src",
"${workspaceFolder}/tracker",
"${workspaceFolder}/NvDecoder",
"/usr/local/cuda-10.1/include"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
2、要启动调试,对编译后的可执行文件进行调试,配置launch.json文件
,vscode需要知道编译的可调式的可执行文件的目录,以及带进去的参数,这些内容需要配置到launch.json中。按F5启动调试,选择GDB环境,编辑launch.json如下所示:主要修改program和args,具体参数请根据自己具体的情况配置;
{
// 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}/darknet",
"args": ["test2.mp4"],//input args
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
3 、使用vscode 进行make 编译用task.json文件
{
"tasks": [
{
"type": "shell",
"label": "obj",
"command": "make -j24",
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
],
"version": "2.0.0"
}
ctr+shift+b