vscode配置cmake插件,进行debug
配置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": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
// Resolved by CMake Tools:
"program": "${command:cmake.launchTargetPath}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
运行vscode左下角的角标,如下
依次运行,cmake,build,debug
其中将[all]切换为想要进行debug的可执行文件
点击debug(虫子型图标),会提示`Target debugging is no longer supported with the legacy driver`
解决方法:
查看自己的cmake版本,ubuntu16.04 默认安装的cmake为3.5.1版本
vscode的cmake插件要求cmake>=3.7.1
更新自己的cmake,重新打开vscode,依次运行,cmake,build,debug即可
扫描二维码关注公众号,回复:
2609915 查看本文章
![](/qrcode.jpg)
附cmake更新教程,转自
1. 卸载已经安装的旧版的CMake[非必需]
apt-get autoremove cmake
2. 文件下载解压:
wget https://cmake.org/files/v3.9/cmake-3.9.1-Linux-x86_64.tar.gz
解压:
tar zxvf cmake-3.9.1-Linux-x86_64.tar.gz
查看解压后目录:
tree -L 2 cmake-3.9.1-Linux-x86_64
cmake-3.9.1-Linux-x86_64
├── bin
│ ├── ccmake
│ ├── cmake
│ ├── cmake-gui
│ ├── cpack
│ └── ctest
├── doc
│ └── cmake
├── man
│ ├── man1
│ └── man7
└── share
├── aclocal
├── applications
├── cmake-3.9
├── icons
└── mime
12 directories, 5 files
bin下面有各种cmake家族的产品程序.
3. 创建软链接
注: 文件路径是可以指定的, 一般选择在/opt
或 /usr
路径下, 这里选择/opt
mv cmake-3.9.1-Linux-x86_64 /opt/cmake-3.9.1
ln -sf /opt/cmake-3.9.1/bin/* /usr/bin/
然后执行命令检查一下:
>>>cmake --version
cmake version 3.9.1
CMake suite maintained and supported by Kitware (kitware.com/cmake).
>>>
>>>cmake-gui
OK。现在cmake最新版本安装成功。
CMake的官方书籍很贵,并且总是晚于实际最新版本,如果想看最新的文档,建议参考:
https://cmake.org/cmake-tutorial/