【发布时间】:2020-04-06 10:52:31
【问题描述】:
我在 Ubuntu 18.04 上使用 Visual Studio Code 进行 C++ 编码。
我发现对于调试,我应该始终构建一个 a.out 文件,然后使用调试器。如果我直接通过 ctrl+alt+n 运行代码,那么代码会完全运行,但它不会给我一个 a.out 文件。
有什么方法可以使这个过程自动化吗?
我还注意到没有可用的构建选项。
这是 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"
}
]
}
【问题讨论】:
-
在您的 Ubuntu 上安装用于 C++ 开发的 Eclipse。您将拥有一个 IDE、一个用于调试的图形 GUI、图形项目配置……
-
请编辑您的问题并添加您用于配置工作区的 JSON 文件。
标签: c++ debugging visual-studio-code