如何在VSCode中调试cmake / make项目? [英] How to debug a cmake/make project in VSCode?
问题描述
我正在做一个项目,为了协助建设,我在使用 CMake
。
I'm making a project and in order to assist in building, I'm using CMake
.
但是,我注意到我无法调试。
However, I notice that I can't debug.
这是我的launch.json:
Here's my launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "gdb",
"request": "launch",
"target": "./build/bin/CHIP8",
"cwd": "${workspaceRoot}",
"preLaunchTask": "build"
}
]
}
这是我的task.json:
And here's my tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "cd build && cmake .. && make"
}
]
}
我在网上找不到任何可以解决这个问题的东西,所以我真的不愿意从这里到哪里去。 VSCode文档提供了一个调试使用g ++的示例,但是我使用的是make ---,所以我不确定该怎么做!
I can't find anything online to help with this problem, so I'm really not sure where to go from here. VSCode docs has an example to debug where they use g++, but I'm using make --- so I'm not sure how to do it!
谢谢。 / p>
Thanks.
推荐答案
似乎您已构建程序的发行版。尝试构建程序的调试版本。
It seems you built release version of your program. Try to build debug version of your program.
rm -r build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
make
最好将调试和发行版本分开。
It is better to separate debug and release builds.
mkdir Debug
cd Debug
cmake -DCMAKE_BUILD_TYPE=Debug ..
make
使用 launch.json
的适当更新:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "gdb",
"request": "launch",
"target": "./Debug/bin/CHIP8",
"cwd": "${workspaceRoot}",
"preLaunchTask": "build"
}
]
}
这篇关于如何在VSCode中调试cmake / make项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!