vscode C/C++ 调试配置_vscodec++调试_winter丶的博客-CSDN博客
在vscode中配置c++运行调试环境的准备工作
1 安装必要的扩展 比如:
像gdb也要在终端机器上安装,
2 支持文件。一般来说, c_cpp_properities.json launch.json 和 tasks.json就够了。
可以通过ctrl+shift+p来搜索。
至于launch.json在按F5运行的时候,会有提醒,安装即可。
下边是最重要的设置。
c_cpp_properties.json
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
tasks.json
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g",
"${workspaceFolder}/*.cpp",
"${workspaceFolder}/sub_party/cBase64/*.c",
"${workspaceFolder}/src/Detector/*.cpp"
"${fileDirname}/${fileBasenameNoExtension}",
"-I",
"${workspaceFolder}/sub_party/cBase64",
"-I",
"${workspaceFolder}/include",
"-I",
"${workspaceFolder}/include/hk_include/base",
"-I",
"${workspaceFolder}/src/Detector",
"-L",
"${workspaceFolder}/lib/common",
"-l",
"curl"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
task,json这样配置一般就够了。
重要的是,在args里边,要把所有的cpp或者c文件,加入进来,因为如果用cmake会同步生成自己的依赖库或者在-l中等效地添加三方依赖库。可执行文件运行时能够找到。但是在vscode中运行的话,需要制定所有自己的源文件,以便生成需要的函数入口。