tka*_*zik 2 c++ linux json visual-studio-code
我的目标是为 Linux (Ubuntu) 下的 C++ 开发设置 VS Code。我查看了大量的教程/视频和WSL的官方文档。不幸的是,我有烦恼放在一起的tasks.json,并launch.json为“纯粹的Linux / WSL没有”建设和调试。我正在寻找这两个文件的最新版本,它们尽可能通用(在 json 文件中尽可能使用变量)。
非常感谢!
PS:我c_cpp_properties.json目前看起来像这样:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/g++",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
Run Code Online (Sandbox Code Playgroud)
试试这个.vscode/launch.json:
{
// 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": "g++ build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
Run Code Online (Sandbox Code Playgroud)
并且.vscode/tasks.json:
{
"tasks": [
{
"type": "shell",
"label": "g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "/usr/bin"
}
}
],
"version": "2.0.0"
}
Run Code Online (Sandbox Code Playgroud)