linux下配置vscode 除錯c++ 專案
阿新 • • 發佈:2019-01-09
每一個部落格都是從坑裡跳出啦的跳後感!!!
vscode 下除錯c++專案:
- 配置 launch.json:
//launch.json
{
“version”: “0.2.0”,
“configurations”: [
{
“name”: “C++ Launch”,
“type”: “cppdbg”,
“request”: “launch”,
“program”: “${workspaceRoot}/Test.out”, //lookout!!!!
“args”: [],
“stopAtEntry”: false,
“cwd”: “${workspaceRoot}”,
“environment”: [],
“externalConsole”: true,
“preLaunchTask”: “g++”, //lookout!!!!
“linux”: {
“miDebuggerPath”: “/usr/bin/gdb”, //lookout!!!!
“MIMode”: “gdb”,
“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”: “0.1.0”,
“command”: “g++”, //這裡將”echo”修改為“g++”
“isShellCommand”: true,
“args”: [ //這裡是編譯引數,和 編譯命令 中引數一一對應就行了
“-g”, //生成除錯資訊
“workspaceRoot/Test.cpp”,//源文件一“ {workspaceRoot}/speak.cpp”, //原始檔二(可省略)
“-o”, //編譯引數
“${workspaceRoot}/Test.out” //生成的目標檔案(編譯檔案),其名字要與除錯配置檔案:launch.json中的名字相同
],
“showOutput”: “always”
}
注意:
每一個工程都的配置一下, 就是重新寫一個makefile檔案一樣!!!不爽也得寫,這比makefile檔案好寫多啦!!!