安装依赖项:
sudo apt-get update
sudo apt-get install git build-essential linux-libc-dev
sudo apt-get install cmake cmake-gui
sudo apt-get install libusb-1.0-0-dev libusb-dev libudev-dev
sudo apt-get install mpi-default-dev openmpi-bin openmpi-common
sudo apt-get install libflann1.8 libflann-dev
sudo apt-get install libeigen3-dev
sudo apt-get install libboost-all-dev
sudo apt-get install libvtk5.10-qt4 libvtk5.10 libvtk5-dev
sudo apt-get install libqhull* libgtest-dev
sudo apt-get install freeglut3-dev pkg-config
sudo apt-get install libxmu-dev libxi-dev
sudo apt-get install mono-complete
sudo apt-get install qt-sdk openjdk-8-jdk openjdk-8-jre
进入源码文件进行编译:
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/pcl18 \ -DBUILD_GPU=ON -DBUILD_apps=ON -DBUILD_examples=ON ..
make -j4
问题1 visualization相关
fatal error: boost/uuid/sha1.hpp: 没有那个文件或目录
103 | #include <boost/uuid/sha1.hpp>
| ^~~~~~~~~~~~~~~~~~~~~
原因:sha1.hpp在电脑中的路径不一致
将pcl_visualizer.cpp文件中 103行的 <boost/uuid/sha1.hpp> 更改为<boost/uuid/detail/sha1.hpp>
问题2 segmentation相关
error: invalid initialization of reference of type ‘const std::vector<float>&’ from expression of type ‘const boost::shared_ptr<std::vector<float> >’
144 | return (plane_coeff_d_);
| ~^~~~~~~~~~~~~~~
解决方法:
在plane_coefficient_comparator.h文件中第144行。
将return(plane_coeff_d_) 更改为 return( *plane_coeff_d_)
问题3 kdtee相关
make[2]: *** [visualization/tools/CMakeFiles/pcl_oni_viewer.dir/build.make:281:bin/pcl_oni_viewer] 错误 1
make[1]: *** [CMakeFiles/Makefile2:2270:visualization/tools/CMakeFiles/pcl_oni_viewer.dir/all] 错误 2
/usr/bin/ld: ../../lib/libpcl_kdtree.so.1.8.0: undefined reference to `LZ4_resetStreamHC'
/usr/bin/ld: ../../lib/libpcl_kdtree.so.1.8.0: undefined reference to `LZ4_setStreamDecode'
/usr/bin/ld: ../../lib/libpcl_kdtree.so.1.8.0: undefined reference to `LZ4_decompress_safe'
/usr/bin/ld: ../../lib/libpcl_kdtree.so.1.8.0: undefined reference to `LZ4_decompress_safe_continue'
/usr/bin/ld: ../../lib/libpcl_kdtree.so.1.8.0: undefined reference to `LZ4_compress_HC_continue'
collect2: error: ld returned 1 exit status
make[2]: *** [visualization/tools/CMakeFiles/pcl_viewer.dir/build.make:283:bin/pcl_viewer] 错误 1
make[1]: *** [CMakeFiles/Makefile2:2208:visualization/tools/CMakeFiles/pcl_viewer.dir/all] 错误 2
打开build子路径下的 link.txt,在末尾添加 -llz4
问题4 outofcore相关
找到pcl-pcl-1.8.0/outofcore/include/pcl/outofcore/impl/octree_disk_container.hpp 文件下的76和77行代码,并将他们注释掉。
问题5 segmentation相关2
error: invalid initialization of reference of type ‘const std::vector<float>&’ from expression of type ‘const boost::shared_ptr<std::vector<float> >’
150 | return (plane_coeff_d_);
找到如下路径中的ground_plane_comparator.h
将第150行代码修改如下:
问题6: undefined reference to symbol 'LZ4_decompress_safe'
/usr/bin/ld: CMakeFiles/pcl_feature_matching.dir/src/feature_matching.cpp.o: undefined reference to symbol 'LZ4_decompress_safe'
/usr/bin/ld: /lib/x86_64-linux-gnu/liblz4.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [apps/CMakeFiles/pcl_feature_matching.dir/build.make:292:bin/pcl_feature_matching] 错误 1
make[1]: *** [CMakeFiles/Makefile2:3754:apps/CMakeFiles/pcl_feature_matching.dir/all] 错误 2
在终端中寻找 liblz4.so的位置
whereis liblz4.so
找到如下路径下pcl_feautre_matching.dir文件夹中的link.txt
将liblz4.so的地址添加到link.txt文件中
终于编译成功了
安装
sudo make install
安装完成后,在使用到pcl1.8代码的CMakeLists.txt中加入:
set(PCL_DIR "/usr/local/pcl18/share/pcl-1.8")
需要兼容 pcl1.10时, 在CMakeLists.txt中加入:
set(PCL_DIR "/usr/include/pcl-1.10")
find_package(PCL 1.10 REQUIRED)
参考链接:
Ubuntu20.04安装PCL1.8.0编译错误(全网最全~)_小方只会百度的博客-CSDN博客
解决undefined reference to symbol ‘LZ4_decompress_safe‘问题_努力搬砖的星期五的博客-CSDN博客_unsing symbol lz4