vscode+C 編譯除錯

slark_yuxj發表於2024-04-28

tasks.json
{
"version": "2.0.0",
"tasks": [
{
"taskName": "shell", // 任務名稱,與launch.json的preLaunchTask相對應
"command": [
"export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/",
"make",
],// 在shell中使用命令,如需加引數,可再新增args屬性
"type":"shell"
}
]
}

launch.json
{
// 使用 IntelliSense 瞭解相關屬性。
// 懸停以檢視現有屬性的描述。
// 欲瞭解更多資訊,請訪問: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",// 配置名稱,將會在啟動配置的下拉選單中顯示
"type": "cppdbg",// 配置型別,這裡只能為cppdbg
"request": "launch",// 請求配置型別,可以為launch(啟動)或attach(附加)
"program": "${workspaceRoot}/permission_manager_dbus_daemon",// 將要進行除錯的程式的路徑
"stopAtEntry": false, // 設為true時程式將暫停在程式入口處,我一般設定為true
"cwd": "${workspaceRoot}",// 除錯程式時的工作目錄
"environment": [],// (環境變數?)
//"externalConsole": true,// 除錯時是否顯示控制檯視窗,一般設定為true顯示控制檯
"MIMode": "gdb",// 指定連線的偵錯程式,可以為gdb或lldb。
"externalConsole": false,
"miDebuggerPath": "/usr/bin/gdb",
"preLaunchTask": "shell" // 除錯會話開始前執行的任務,一般為編譯程式。與tasks.json的taskName相對應,可根據需求選擇是否使用
}
]
}

c_cpp_properties.json
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}

相關文章