gpt4 book ai didi

Ubuntu 20.04 安装 PCL 后由于包含目录不正确而找不到 PCL `sudo apt install libpcl-dev`

转载 作者:行者123 更新时间:2023-12-04 18:48:58 27 4
gpt4 key购买 nike

操作系统:Ubuntu20.04
PCL信息:

Package: libpcl-dev
Version: 1.10.0+dfsg-5ubuntu1
Priority: extra
Section: universe/libdevel
Source: pcl
Origin: Ubuntu
我通过 sudo apt install libpcl-dev 安装了 PCL .并像这样使用它:
cmake_minimum_required(VERSION 3.5)
project(test)

# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-parameter)
endif()

# find dependencies
find_package(PCL REQUIRED)
构建项目时出现一些错误:
CMake Error at /lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:62 (message):
PCL can not be found on this machine
Call Stack (most recent call first):
/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:452 (pcl_report_not_found)
CMakeLists.txt:37 (find_package)


-- Configuring incomplete, errors occurred!
我正在尝试调试 /lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:418-454 中的 cmake 源代码,cmake源码如下图:
find_package(PkgConfig QUIET)

file(TO_CMAKE_PATH "${PCL_DIR}" PCL_DIR)
if(WIN32 AND NOT MINGW)
# PCLConfig.cmake is installed to PCL_ROOT/cmake
get_filename_component(PCL_ROOT "${PCL_DIR}" PATH)
else()
# PCLConfig.cmake is installed to PCL_ROOT/share/pcl-x.y
get_filename_component(PCL_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../../.." ABSOLUTE)
endif()

# check whether PCLConfig.cmake is found into a PCL installation or in a build tree
if(EXISTS "${PCL_ROOT}/include/pcl-${PCL_VERSION_MAJOR}.${PCL_VERSION_MINOR}/pcl/pcl_config.h")
# Found a PCL installation
# pcl_message("Found a PCL installation")
set(PCL_CONF_INCLUDE_DIR "${PCL_ROOT}/include/pcl-${PCL_VERSION_MAJOR}.${PCL_VERSION_MINOR}")
set(PCL_LIBRARY_DIRS "${PCL_ROOT}/lib/x86_64-linux-gnu")
if(EXISTS "${PCL_ROOT}/3rdParty")
set(PCL_ALL_IN_ONE_INSTALLER ON)
endif()
elseif(EXISTS "${PCL_ROOT}/include/pcl/pcl_config.h")
# Found a non-standard (likely ANDROID) PCL installation
# pcl_message("Found a PCL installation")
set(PCL_CONF_INCLUDE_DIR "${PCL_ROOT}/include")
set(PCL_LIBRARY_DIRS "${PCL_ROOT}/lib")
if(EXISTS "${PCL_ROOT}/3rdParty")
set(PCL_ALL_IN_ONE_INSTALLER ON)
endif()
elseif(EXISTS "${PCL_DIR}/include/pcl/pcl_config.h")
# Found PCLConfig.cmake in a build tree of PCL
# pcl_message("PCL found into a build tree.")
set(PCL_CONF_INCLUDE_DIR "${PCL_DIR}/include") # for pcl_config.h
set(PCL_LIBRARY_DIRS "${PCL_DIR}/lib/x86_64-linux-gnu")
set(PCL_SOURCES_TREE "/build/pcl-gWGA5r/pcl-1.10.0+dfsg")
else()
pcl_report_not_found("PCL can not be found on this machine")
endif()
通过调试,发现环境变量PCL_ROOT设置为 /PCL_DIR设置为 /lib/x86_64-linux-gnu/cmake/pcl .因此,它找不到正确的 PCL 包含目录(正确的 PCL 包含目录是 /usr/include/pcl-1.10 )并导致 cmake 错误。
那么,我的 PCL 有什么问题,如何通过 find_package(PCL REQUIRED) 找到 PCL?成功地?非常感谢!

最佳答案

“更改位置”的一种简单方法是创建符号链接(symbolic link)。在这种情况下,你会这样做:

sudo mkdir /lib/x86_64-linux-gnu/cmake/pcl/include
sudo ln -s /usr/include/pcl-1.10/pcl /lib/x86_64-linux-gnu/cmake/pcl/include/pcl
然后你可能会遇到:
No such file or directory
#include <Eigen/Core>
用同样的方法修复它:
sudo ln -s /usr/include/eigen3/Eigen /usr/include/Eigen

关于Ubuntu 20.04 安装 PCL 后由于包含目录不正确而找不到 PCL `sudo apt install libpcl-dev`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66669735/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com