CMake之 find_package
“轻松搞定CMake”系列之find_package用法详解
cmake编译时出现 /usr/bin/ld: cannot find -lBoost::timer
打开CMakeLists.txt, 加入
find_package(Boost REQUIRED COMPONENTS timer)
即可
VScode调试ROS节点
编译
task.json
{
"version": "2.0.0",
"tasks": [
{
"label":"catkin_make:debug", //代表提示的描述信息
"type": "shell", // 可选shell或process, shell:代码在shell里面运行一个命令,process:代表作为一个进程来运行
"command":"catkin_make", // 需要运行的命令
"args": [
"--directory",
"/home/zzx/catkin_ws",
"-DCMAKE_BUILD_TYPE=RelWithDebInfo"
],
"problemMatcher": [
"$catkin-gcc"
],
"group": {"kind":"build","isDefault": true},
"presentation": {
"reveal": "always", //可选always或silence,代表是否输出信息
}
}
]
}
调试节点文件
CMakeLists.txt中添加 set(CMAKE_BUILD_TYPE Debug)
配置launch.json文件
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch", // 配置名称,将会在调试配置下拉列表中显示
"type": "cppdbg", // 调试器类型 该值自动生成
"request": "launch", // 调试方式,还可以选择attach
"program": "${workspaceRoot}/devel/lib/intensity_slam/intensity_slam_isc_generation_node", //要调试的程序(完整路径,支持相对路径)
"args": [], // 传递给上面程序的参数,没有参数留空即可
"stopAtEntry": false, // 是否停在程序入口点(停在main函数开始)
"cwd": "${workspaceRoot}", // 调试程序时的工作目录
"environment": [], //针对调试的程序,要添加到环境中的环境变量. 例如: [ { "name": "squid", "value": "clam" } ]
"externalConsole": false, //如果设置为true,则为应用程序启动外部控制台。 如果为false,则不会启动控制台,并使用VS Code的内置调试控制台。
"MIMode": "gdb", // VSCode要使用的调试工具名称
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
再启动roscore,即可开始调试节点。