Featured image of post 安装PCL时候踩过的一些小坑

安装PCL时候踩过的一些小坑

安装时大体是参考这个网站这个网站的教程进行安装的。但部分问题不管是在中文互联网还是英文互联网上都没有找到解决方案,所以记录一下。

1、DVTK_WRAP_PYTHON=ON

部分教程在给安装代码时,在cmake的环节会将DVTK_WRAP_PYTHON设置为ON,但是我个人的WSL是没有Python需求也就没有进行过Python环境的配置,所以在cmake的时候,将DVTK_WRAP_PYTHON设置为OFF

2、无法找到Visualization

在安装完成后,我用demo在编译的时候,提示无法找到Visualization,如下图所示:

图中可以将pcl移出pcl-1.9文件夹,这里只是本人偷懒了

visualization库是需要安装vtk的,很多教程基本忽略了这一点,只会告诉你需要安装vtk以及怎么装。

在正确编译并安装正确版本的vtk之后,重新编译demo文件,发现还是无法找到Visualization,于是回去看cmake的输出,发现如下图所示:

如果没有安装vtk这里就会显示vtk not found

发现了大大的visualization: Disabled manually

网上找了下解决方案,然后在某喜爱四迪恩论坛发现了如下的言论:

(`ゥ´ )哥你要不再想想为什么要用Cmake GUI来执行Cmake呢

总之,解决方案就是在Cmake的选项中将BUILD_visualization设置为ON,然后重新编译即可。

这一点不知道为什么在pcl的Github Issue栏也没看到有人提,难道大家的default都是ON吗?

3. 编译时报错undefined reference to vtkDebugLeaksManager::vtkDebugLeaksManager()

鉴定为没好好看教程导致的,cmakelist.txt中没有添加find_package(VTK REQUIRED),添加后重新编译即可。

附上我的cmakelist.txt文件:

cmake_minimum_required(VERSION 3.23)
project(Graduate)

set(CMAKE_CXX_STANDARD 17)

add_executable(Graduate main.cpp)
find_package(PCL 1.9 REQUIRED)
include_directories("/usr/include/eigen3")
include_directories("/usr/local/include/vtk-8.2")
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})


target_link_libraries(Graduate ${PCL_LIBRARIES})

4. error while loading shared libraries: libvtkRenderingCore-8.2.so.1

参考这篇

不知道这个vtk的库为什么没直接装到/usr/local/lib/里面,而是装到了/usr/local/lib/x86_64-linux-gnu 里面。

解决方法

cat /etc/ld.so.conf
sudo sh -c "echo '/usr/local/lib/x86_64-linux-gnu' >> /etc/ld.so.conf"
sudo sh -c "ldconfig"

5. [xcb] Unknown sequence number while processing queue

编译通过了,但是运行demo的时候,出现了如下的错误:

[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that. Graduate: ../../src/xcb_io.c:260: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.****

解决方法

在开头加上这句

#include <X11/Xlib.h>
//避免和Eigen冲突
#ifdef Success
#undef Success
#endif

在main函数中加上这句

XInitThreads();
Licensed under CC BY-NC-SA 4.0
最后更新于 Nov 11, 2023 14:35 CST