1.vscode下载Remote Development、Dev Containers插件
2.开启docker容器
3.vscode 连接容器
4.修改task.json和lauch.json

task.
json文件
{
"tasks": [
{
"label": "build",
"type": "shell",
"command": "gcc",
"args": [
"${file}", // 你的源代码文件名
"-o", "${fileDirname}/${fileBasenameNoExtension}",
"-pthread", // 必须加这个,链接线程库
"-g" // 生成调试信息
],
"group": {
"kind": "build",
"isDefault": true
}
}
],
"version": "2.0.0"
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "C Debug",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}", // 你的可执行文件路径
"args": [],
"stopAtEntry": true, // 程序启动时就暂停,方便一步步调试
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build", // 调试前先编译
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
成功在vscode编译运行
9108

被折叠的 条评论
为什么被折叠?



