错误可参考:Ubuntu20.04 编译 pcl1.8可能出现的问题
安装参考1:ubuntu20.04下安装pcl_ubuntu安装pcl_Yuannau_jk的博客-CSDN博客
安装参考2:Ubuntu20.04 安装pcl详细教程_ubuntu20.04安装pcl_LYiiiiiii的博客-CSDN博客
安装参考3:PCL1.12+VTK7.1.1 && Ubuntu20.04.3+VSCode(官网最新版2022.01) - 知乎
安装过程
1.安装依赖
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
sudo apt-get install libx11-dev libxext-dev libxtst-dev libxrender-dev libxmu-dev libxmuu-dev
sudo apt-get install build-essential libgl1-mesa-dev libglu1-mesa-dev
sudo apt-get install cmake cmake-gui
2.安装VTK
VTK下载:VTK-7.1.1.zip
tar -zvxf VTK-7.1.1.tar.gz #根据下载的版本,解压到想要的文件夹下
mkdir build
cd build
cmake-gui
配置 where is the source code 为VTK-7.1.1所在目录;
配置 where to build the binaries 为VTK-7.1.1下的build文件夹;
点击“Configure”,(用“Unix Makefiles”就可以);配置完成后,显示“Configuring done”。
ps.框里不能报红,红了就是缺少东西了,不选正确后面PCL安装不上!!
在没有任何报红情况下,再点击“Configure”;配置完成后,显示“Configuring done”;
点击“Generate”;显示“Generating done”。
#在build文件夹下
make -j8 # 8核处理器。电脑硬件不行就使用make
sudo make install
vtk安装完成。
———————————————————————————————————————————
cmake-gui编译VTK可能遇到的问题
错误1:“/usr/bin/ld: cannot find -lvtkIOMPIImage /usr/bin/ld: cannot find -lvtkIOMPIParallel /usr/bin/ld: cannot find -lvtkFiltersParallelDIY2”
解决:重新configure vtk,勾选“Advanced”,在search中把/usr/bin/ld找不到的vtkIOMPIImage,vtkIOMPIParallel,vtkFiltersParallelDIY2都选上。
错误2:在configure VTK-7.1.1时,提示:要求必须用qt4;类似于“Found unsuitable Qt version "" from NOTFOUND, this code requires Qt 4.x”这样的一段提示。
解决:ubuntu20.04安装qt4_nicholas_duan的博客
错误3:OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for compatibility with CMake 3.10 and below the legacy GL library will be used. Call Stack (most recent call first): CMake/vtkOpenGL.cmake:77 (find_package) Rendering/OpenGL2/CMakeLi
解决:在/VTK-7.1.1/CMakeLists.txt文件中加入下面内容。
错误4:CMake Deprecation Warning at ThirdParty/libproj4/vtklibproj4/cmake/policies.cmake:2 (cmake_policy):
The OLD behavior for policy CMP0022 will be removed from a future version
of CMake.The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
ThirdParty/libproj4/vtklibproj4/CMakeLists.txt:43 (include)解决:在 /VTK-7.1.1/ThirdParty/libproj4/vtklibproj4/cmake/policies.cmake修改如下
错误5:CMake Deprecation Warning at ThirdParty/libproj4/vtklibproj4/cmake/policies.cmake:2 (cmake_policy):> The OLD behavior for policy CMP0022 will be removed from a future version of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all policies are deprecated and that a policy should be set to OLD only under specific short-term circumstances. Projects should be ported to the NEW behavior and not rely on setting a policy to OLD. Call Stack (most recent call first): ThirdParty/libproj4/vtklibproj4/CMakeLists.txt:43 (include)
解决:/VTK-7.1.1/ThirdParty/libproj4/vtklibproj4/cmake/policies.cmake对应与Policy CMP0022修改。if (CMAKE_MAJOR_VERSION GREATER 2) cmake_policy(SET CMP0022 NEW) # interface link libraries cmake_policy(SET CMP0042 NEW) # osx rpath cmake_policy(SET CMP0011 NEW) # policy setting endif()
PCL
可参考:Ubuntu18.04安装PCL 1.9.1_振华OPPO的博客
PCL编译出错参考:Ubuntu20.04安装PCL1.8.0编译错误_小方只会百度的博客
1.下载地址: Release PCL 1.12.0 · PointCloudLibrary/pcl · GitHub
cd pcl的目录
mkdir build
cd build
cmake -DCMAKE_TYPE=None ..
make -j8
sudo make install
#pcl安装完成
出现的错误可能都是因为VTK,上面重新configure。VTK 的Configure有报红没解决。VTK在cmake-gui界面内没有
configure好就generate..后续pcl的make和install都会导致失败。
cmake编译PCL遇到的问题
(1)ClangFormat
问题描述:Could NOT find ClangFormat (missing: ClangFormat_EXECUTABLE ClangFormat_VERSION) (Required is at least version “10”)
解决方法:sudo apt-get install clang-format-10
(2)metslib
问题描述:Checking for module ‘metslib’ – No package ‘metslib’ found
解决方法:下载并安装metslib包,下载链接: metslib-0.5.3.,解压并进入metslib-0.5.3文件夹,然后执行
sudo sh ./configure
sudo make
sudo make install
(3)PNG
问题描述:Could NOT find PNG (missing: PNG_LIBRARY PNG_PNG_INCLUDE_DIR)
解决方法:sudo apt-get install libpng-dev
(4)PCAP
问题描述:Could NOT find Pcap (missing: PCAP_LIBRARIES PCAP_INCLUDE_DIRS)
解决方法:安装pcap包,依次执行
git clone https://github.com/the-tcpdump-group/libpcap
cd libpcap
./configure # 可能会遇到 configure: error: Neither flex nor lex was found. 见下“注”
make -j8
sudo make install
注:如果在./configure时出现 configure: error: Neither flex nor lex was found.
运行:sudo apt-get install flex bison
(5)GLEN
问题描述:Could NOT find GLEW (missing: GLEW_INCLUDE_DIR GLEW_LIBRARY)
解决方法:sudo apt install libglew-dev