c++ - 如何设置 VSCode 调试器以使用 cmake?
问题描述
我在这里发现了一个非常接近的问题,但是从那时起 C++ 扩展已经更新launch.json
,为您创建的文件非常不同,我不知道如何设置它。网上也没有很多信息可以做到这一点,所以我希望有人以前做过。我目前的项目结构是这样的:
MainProj
./build
CMakeLists.txt
main.cpp
otherClasses.hpp
而build
运行后..cmake
出现的cmake目标make
被调用Main
。
启动.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"
}
]
}
这是另一个问题的 tasks.json 文件
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "cd build && cmake .. && make"
}
]
}
解决方案
推荐阅读
- javascript - 根据 id 更新对象,错误 'this.props.update' is not a function
- mongodb - 管理 docker 卷中的数据
- arrays - vuejs 使用 Element UI 中的 el-select 在 v-for 中维护状态
- python - 如何防止在同一索引中分配元素?
- discord - 如何用 message.content 中的用户名替换 id
- sql - 如何根据连接属性的最接近值左连接两个表?
- android - Cordova 9 没有从我的自定义插件中将服务标签添加到 AndroidManifest.xml
- typescript - 如何返回从 TS 中的数组中提取的相应(按索引)窄类型的记录
- java - VirtualMachine.attach(pid) 失败并出现 java.io.IOException:无法附加到当前 VM
- javascript - Google Visualization API - JQuery - 在 ColumnChart 中每两个条增加间距