PointCloudLibrary / PointCloudLibrary/pcl

[compile error] "can't found PCL because of wrong PCL_ROOT"

Open
#4,661 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind: compile error status: triage
Dominant language
C++
Stars
11.1k
Forks
4.7k
Avg merge
4d 10h
Merged PRs (30d)
6

Description

I installed PCL by sudo apt install libpcl-dev. and used it like this:

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)

some errors occurred when I built the project:

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!

I'm trying to debug the cmake source code in /lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:418-454, The cmake source is shown below:

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()

Through debugging, I found that the environment variable PCL_ROOT is set to / and PCL_DIR is set to /lib/x86_64-linux-gnu/cmake/pcl. So, It can't find correct PCL include directory(the correct PCL include dir is /usr/include/pcl-1.10) and lead to cmake error.

My Environment :

  • OS: [Ubuntu 20.04]
  • Compiler: [GCC 9.3.0]
  • PCL Version [1.10 ]
  • PCL Type: [Installed]
    some more info about pcl
Package: libpcl-dev
Version: 1.10.0+dfsg-5ubuntu1
Priority: extra
Section: universe/libdevel
Source: pcl
Origin: Ubuntu

So, what's the problem with my PCL, and how can I find PCL by find_package(PCL REQUIRED) successfully? Thanks a lot!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with /lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake lines 418-454 and the CMakeLists.txt call to find_package(PCL REQUIRED). Compare the computed PCL_ROOT and PCL_DIR with the installed include path /usr/include/pcl-1.10, then reproduce the configuration using the reported Ubuntu 20.04 and libpcl-dev versions. Done means the cause is identified and find_package(PCL REQUIRED) configures successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.