pcl icon indicating copy to clipboard operation
pcl copied to clipboard

CMake find_package(PCL) overwrites Boost_LIBRARIES

Open 3dteemu opened this issue 10 years ago • 4 comments

This code does not work:

find_package(Boost COMPONENTS chrono program_options system filesystem thread date_time regex serialization REQUIRED)
find_package(PCL 1.7 REQUIRED)

This works:

find_package(PCL 1.7 REQUIRED)
find_package(Boost COMPONENTS chrono program_options system filesystem thread date_time regex serialization REQUIRED)

In the former example, Boost_LIBRARIES won't contain e.g. libboost_program_options.so.

  • cmake version 2.8.12.2
  • PCL version 1.7.2 from ppa:v-launchpad-jochen-sprickerhof-de/pcl
  • Boost version 1.57.0
  • Ubuntu 14.04

3dteemu avatar Jul 14 '15 09:07 3dteemu

Marking this as stale due to 30 days of inactivity. It will be closed in 7 days if no further activity occurs.

stale[bot] avatar May 19 '20 20:05 stale[bot]

Confirmed as still present in PCL

kunaltyagi avatar May 21 '20 21:05 kunaltyagi

Still present. The above fix does not work in my case - there seems to be a problem with boost::program_options. I modified the CMake example from the documentation to showcase the error:

cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(MY_GRAND_PROJECT)
find_package(PCL 1.3 REQUIRED COMPONENTS common io)
find_package(Boost REQUIRED COMPONENTS system program_options)
include_directories(${PCL_INCLUDE_DIRS} ${BOOST_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(pcd_write_test pcd_write.cpp)
target_link_libraries(pcd_write_test ${PCL_LIBRARIES} ${BOOST_LIBRARIES})

And the Code as follows:

   #include <iostream>
   #include <pcl/io/pcd_io.h>
   #include <pcl/point_types.h>
   #include <boost/program_options.hpp>
  
   namespace bpo = boost::program_options;
  
   int
     main ()
  {
     bpo::options_description desc("Options");
     desc.add_options()("help, h", "show help");
 
    pcl::PointCloud<pcl::PointXYZ> cloud;
 
    // Fill in the cloud data
    cloud.width    = 5;
...

The program compiles just fine, but results in a linker error:

[ 50%] Linking CXX executable pcd_write_test
/nix/store/5ddb4j8z84p6sjphr0kh6cbq5jd12ncs-binutils-2.35.1/bin/ld: CMakeFiles/pcd_write_test.dir/pcd_write.cpp.o: in function `main':
pcd_write.cpp:(.text.startup+0x2c): undefined reference to `boost::program_options::options_description::m_default_line_length'
/nix/store/5ddb4j8z84p6sjphr0kh6cbq5jd12ncs-binutils-2.35.1/bin/ld: pcd_write.cpp:(.text.startup+0x64): undefined reference to `boost::program_options::options_description::options_description(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, unsigned int)'
/nix/store/5ddb4j8z84p6sjphr0kh6cbq5jd12ncs-binutils-2.35.1/bin/ld: pcd_write.cpp:(.text.startup+0x94): undefined reference to `boost::program_options::options_description::add_options()'
/nix/store/5ddb4j8z84p6sjphr0kh6cbq5jd12ncs-binutils-2.35.1/bin/ld: pcd_write.cpp:(.text.startup+0xbf): undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, char const*)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/pcd_write_test.dir/build.make:181: pcd_write_test] Error 1
make[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/pcd_write_test.dir/all] Error 2
make: *** [Makefile:103: all] Error 2

dsxmachina avatar Dec 09 '21 08:12 dsxmachina

@dsxmachina Did you try with ${Boost_LIBRARIES} instead of ${BOOST_LIBRARIES}? Same for the other Boost variables

mvieth avatar Jan 05 '22 19:01 mvieth