在VScode中借用CMake指令Debug PCL代码
在Ubuntu18.04中,借用VScode对PCL代码进行Debug
在直接使用g++ 编译PCL时会一直显示无法搜索到某些库,故借用Cmake指令生成可执行文件之后在用VScode进行Debug
1.CMakeLiset.txt 文件的编写
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(my_main) // 项目的名字
find_package(PCL 1.8 REQUIRED) //使用pcl-1.8版本
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
set(CMAKE_BUILD_TYPE "Debug") //设置生成的可执行文件可以进行Debug操作,一定要写!!
add_executable(my_main my_main.cpp my_head.h my_head.cpp)
target_link_libraries (my_main ${PCL_LIBRARIES})
2.task.json 文件的编写
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "cd ./build ;cmake .. ;make",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "clean",
"type": "shell",
"command": "make clean",
}
]
}
3.launch.json 文件编写
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) 启动",
"type": "cppdbg",
"request": "launch",
"preLaunchTask": "cmakebuild",
"program": "${workspaceFolder}/build/my_main",
"args": ["1.pcd"],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
以上3个VScode是最基本的配置,如果还需要实现其他的功能,可以在对应的文件上进行改善。
|