File "PCLConfig.cmake" will unexpectedly change BOOST_ROOT and lead to link error

Bug #1928819 reported by Jialiang Kang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pcl (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

In PCLConfig.cmake line 115&116 says:

if(PCL_ALL_IN_ONE_INSTALLER)
    set(BOOST_ROOT "${PCL_ROOT}/3rdParty/Boost")

,in which PCL_ALL_IN_ONE_INSTALLER has already set to be ON in line 435 through a normal apt install procedure. That will lead to a link error of libboost, if we firstly find boost and then find pcl. The following is a simple example of CMakeList.txt:

cmake_minimum_required(VERSION 3.16)

project(main)

find_package(
  Boost
  COMPONENTS
  system
  thread
  chrono
  REQUIRED
  )
find_package(
  PCL
  REQUIRED
  )

include_directories(
  ${Boost_INCLUDE_DIRS}
  )
link_directories(
  ${Boost_LIBRARY_DIRS}
  )

add_executable(main main.cpp)

target_link_libraries(
 main
 ${Boost_LIBRARIES}
 )

Any used boost functions in main.cpp will lead to link error like this: main.cpp:5: undefined reference to `boost::thread::hardware_concurrency()', even though pcl remains unused in the cpp file. Simply move find_package(Boost ...) to the back of find_package(PCL ...) will solve the problem, because now we are using the boost lib provided by pcl.However, such a solution is not stragihtforward at all anc hart to be figured out. Hope you can help to remove such a confusing change of BOOST_ROOT, given that libboost-dev can also easily get installed by apt and already exists in many ubuntus.

Revision history for this message
Jochen Sprickerhof (v-launchpad-jochen-sprickerhof-de) wrote :

I assume you are using libpcl-dev_1.10.0 (Ubuntu 20.04) or libpcl-dev_1.11.1 (Ubuntu 20.10 and 21.04) based on that line 435 should set PCL_ALL_IN_ONE_INSTALLER to ON. That would be this line in git: https://github.com/PointCloudLibrary/pcl/blob/pcl-1.11.1/PCLConfig.cmake.in#L411
PCL_ROOT is set to /usr in the package, so there would need to be a /usr/3rdParty folder on your system to trigger this behavior. That is not a path provided by Ubuntu and I would propose to remove it from your system and see if it fixes your problem.

I've send a PR upstream to fix this: https://github.com/PointCloudLibrary/pcl/pull/4821

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pcl - 1.12.0+dfsg-5build1

---------------
pcl (1.12.0+dfsg-5build1) jammy; urgency=medium

  * No-change rebuild against libproj22

 -- Graham Inggs <email address hidden> Fri, 29 Oct 2021 05:22:15 +0000

Changed in pcl (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.