先简单说明一下我的病情,我的Ubuntu版本是22.04,在没有安装点云之前就已经安装的QT5和Anaconda的运行环境。
开始的时候我是通过直接apt安装PCL库的,但是有点问题,跑网上给的例程代码的时候,生成点云的视图时候,就是闪一下,然后报“Segmentation fault (core dumped)”错误,具体原因我也不清楚,不知道为什么,就是不能可视化,其他的似乎都没有问题。
//安装
sudo apt-get update
sudo apt-get install libpcl-dev pcl-tools
sudo apt-get install ros-kinetic-pcl-conversions
//卸载
sudo apt-get --purge remove libpcl-dev

所以我还是决定直接对源码进行编译安装。安装的点云版本是PCL1.12.1 + VTK9.2.6。
VTK9.2.6库的编译
先说说编译VTK9.2.6遇到的问题,下面是编译过程中遇到的问题,编译的过程可以网上大致都有,我直接列出我遇到的错误:
CMake Error at /usr/local/share/cmake-3.25/Modules/CMakeDetermineCompilerId.cmake:739 (message):
Compiling the CUDA compiler identification source file
"CMakeCUDACompilerId.cu" failed.
Compiler: /usr/local/cuda/bin/nvcc
Build flags:
Id flags: --keep;--keep-dir;tmp -v
The output was:
#$ _NVVM_BRANCH_=nvvm
#$ _SPACE_=
#$ _CUDART_=cudart
#$ _HERE_=/usr/local/cuda/bin
#$ _THERE_=/usr/local/cuda/bin
#$ _TARGET_SIZE_=
#$ _TARGET_DIR_=
#$ _TARGET_DIR_=targets/x86_64-linux
#$ TOP=/usr/local/cuda/bin/..
#$ NVVMIR_LIBRARY_DIR=/usr/local/cuda/bin/../nvvm/libdevice
#$
LD_LIBRARY_PATH=/usr/local/cuda/bin/../lib:/usr/local/cuda/lib64:/usr/local/cuda-11.4/lib64::/usr/local/arm_gcc/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/lib
#$
PATH=/usr/local/cuda/bin/../nvvm/bin:/usr/local/cuda/bin:/home/eagle/anaconda3/bin:/usr/local/cuda/bin:/opt/Qt5.12.8/5.12.8/gcc_64:/opt/Qt5.12.8/Tools/QtCreator/bin:/home/eagle/.local/bin:/usr/local/cuda-11.4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/usr/local/arm_gcc/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin
#$ INCLUDES="-I/usr/local/cuda/bin/../targets/x86_64-linux/include"
#$ LIBRARIES= "-L/usr/local/cuda/bin/../targets/x86_64-linux/lib/stubs"
"-L/usr/local/cuda/bin/../targets/x86_64-linux/lib"
#$ CUDAFE_FLAGS=
#$ PTXAS_FLAGS=
#$ rm tmp/a_dlink.reg.c
#$ gcc -D__CUDA_ARCH__=520 -E -x c++ -DCUDA_DOUBLE_MATH_FUNCTIONS
-D__CUDACC__ -D__NVCC__
"-I/usr/local/cuda/bin/../targets/x86_64-linux/include"
-D__CUDACC_VER_MAJOR__=11 -D__CUDACC_VER_MINOR__=4
-D__CUDACC_VER_BUILD__=48 -D__CUDA_API_VER_MAJOR__=11
-D__CUDA_API_VER_MINOR__=4 -include "cuda_runtime.h" -m64
"CMakeCUDACompilerId.cu" -o "tmp/CMakeCUDACompilerId.cpp1.ii"
In file included from
/usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h:83,
from <command-line>:
/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/host_config.h:139:2:
error: #error -- unsupported GNU version! gcc versions later than 10 are
not supported! The nvcc flag '-allow-unsupported-compiler' can be used to
override this version check; however, using an unsupported host compiler
may cause compilation failure or incorrect run time execution. Use at your
own risk.
139 | #error -- unsupported GNU version! gcc versions later than 10 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
| ^~~~~
# --error 0x1 --
Call Stack (most recent call first):
/usr/local/share/cmake-3.25/Modules/CMakeDetermineCompilerId.cmake:6 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
/usr/local/share/cmake-3.25/Modules/CMakeDetermineCompilerId.cmake:48 (__determine_compiler_id_test)
/usr/local/share/cmake-3.25/Modules/CMakeDetermineCUDACompiler.cmake:307 (CMAKE_DETERMINE_COMPILER_ID)
cmake/pcl_find_cuda.cmake:13 (enable_language)
CMakeLists.txt:363 (include)
这个问题实在没有不懂,最后还是让chatGPT解决了(chatGPT牛批)。
该错误显示您使用的gcc版本高于10,而CUDA不支持高于10的gcc版本。您可以尝试使用
-allow-unsupported-compiler选项覆盖版本检查,但使用不受支持的主机编译器可能会导致编译失败或不正确的运行时执行。建议您将gcc降级到10以下版本,以便与CUDA兼容。如果您使用的是Ubuntu操作系统,您可以通过以下命令降级gcc版本:
具体解决方法如下:
sudo apt-get install gcc-10 g++-10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10
最后编译VTK库安装,就可以啦。
PCL-1.12.1库的编译
这里需要说明一下,最好对cmake进行如下配置,尤其是GPU这个选项(表示启用计算机的GPU上加速算法编译),否则性能差一点的电脑编着编就寄了…(比如我的电脑)。
cd pcl-pcl-1.12.1/
# 创建目录
mkdir release
# 进入目录
cd release
# 配置cmake
cmake -DCMAKE_BUILD_TYPE=None \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DBUILD_GPU=ON \
-DBUILD_apps=ON \
-DBUILD_examples=ON ..
# 进行编译 4为内核数 按自己的cpu内核填写 不写数字默认使用全部核心编译
make -j4
sudo make install
最后看一下效果图
接下就可以使用PCL点云库啦!


509

被折叠的 条评论
为什么被折叠?



