PointCloudLibrary / pcl

Point Cloud Library (PCL)
https://pointclouds.org/
Other
9.72k stars 4.6k forks source link

"pcl_common" was not found during compilation #5042

Closed MasHyke closed 2 years ago

MasHyke commented 2 years ago

I am trying to build my first program using PCL, however during compilation, ament_target_dependencies() complains that it does not find 'pcl_common'. However in the build logs, it seems like it does actually find it, however it says 'PCL_COMMON' instead. Why does this happen, and what is the workaround?

From the terminal:

Starting >>> pointcloud_detector
--- stderr: pointcloud_detector                         
** WARNING ** io features related to openni will be disabled
** WARNING ** io features related to openni2 will be disabled
** WARNING ** io features related to pcap will be disabled
** WARNING ** io features related to png will be disabled
** WARNING ** io features related to libusb-1.0 will be disabled
** WARNING ** visualization features related to openni will be disabled
** WARNING ** visualization features related to openni2 will be disabled
** WARNING ** apps features related to openni will be disabled
CMake Error at /opt/ros/foxy/share/ament_cmake_target_dependencies/cmake/ament_target_dependencies.cmake:77 (message):
  ament_target_dependencies() the passed package name 'pcl_common' was not
  found before
Call Stack (most recent call first):
  CMakeLists.txt:32 (ament_target_dependencies)

---
Failed   <<< pointcloud_detector [1.87s, exited with code 1]

Summary: 0 packages finished [1.97s]
  1 package failed: pointcloud_detector
  1 package had stderr output: pointcloud_detector

From the streams.log:

[1.802s] -- looking for PCL_COMMON
[1.803s] -- Found PCL_COMMON: /usr/lib/x86_64-linux-gnu/libpcl_common.so  
[1.803s] -- looking for PCL_KDTREE
[1.804s] -- Found PCL_KDTREE: /usr/lib/x86_64-linux-gnu/libpcl_kdtree.so  
[1.804s] -- looking for PCL_OCTREE
[1.805s] -- Found PCL_OCTREE: /usr/lib/x86_64-linux-gnu/libpcl_octree.so  
[1.805s] -- looking for PCL_SEARCH
[1.806s] -- Found PCL_SEARCH: /usr/lib/x86_64-linux-gnu/libpcl_search.so  
[1.806s] -- looking for PCL_SAMPLE_CONSENSUS
[1.807s] -- Found PCL_SAMPLE_CONSENSUS: /usr/lib/x86_64-linux-gnu/libpcl_sample_consensus.so  
[1.808s] -- looking for PCL_FILTERS
[1.808s] -- Found PCL_FILTERS: /usr/lib/x86_64-linux-gnu/libpcl_filters.so  
[1.809s] -- looking for PCL_2D
[1.809s] -- Found PCL_2D: /usr/include/pcl-1.10  
[1.810s] -- looking for PCL_GEOMETRY
[1.810s] -- Found PCL_GEOMETRY: /usr/include/pcl-1.10  
[1.810s] -- looking for PCL_IO
[1.811s] -- Found PCL_IO: /usr/lib/x86_64-linux-gnu/libpcl_io.so  
[1.811s] -- looking for PCL_FEATURES
[1.814s] -- Found PCL_FEATURES: /usr/lib/x86_64-linux-gnu/libpcl_features.so  
[1.814s] -- looking for PCL_ML
[1.815s] -- Found PCL_ML: /usr/lib/x86_64-linux-gnu/libpcl_ml.so  
[1.815s] -- looking for PCL_SEGMENTATION
[1.816s] -- Found PCL_SEGMENTATION: /usr/lib/x86_64-linux-gnu/libpcl_segmentation.so  
[1.816s] -- looking for PCL_VISUALIZATION
[1.817s] -- Found PCL_VISUALIZATION: /usr/lib/x86_64-linux-gnu/libpcl_visualization.so  
[1.817s] -- looking for PCL_SURFACE
[1.818s] -- Found PCL_SURFACE: /usr/lib/x86_64-linux-gnu/libpcl_surface.so  
[1.818s] -- looking for PCL_REGISTRATION
[1.819s] -- Found PCL_REGISTRATION: /usr/lib/x86_64-linux-gnu/libpcl_registration.so  
[1.819s] -- looking for PCL_KEYPOINTS
[1.820s] -- Found PCL_KEYPOINTS: /usr/lib/x86_64-linux-gnu/libpcl_keypoints.so  
[1.820s] -- looking for PCL_TRACKING
[1.821s] -- Found PCL_TRACKING: /usr/lib/x86_64-linux-gnu/libpcl_tracking.so  
[1.822s] -- looking for PCL_RECOGNITION
[1.822s] -- Found PCL_RECOGNITION: /usr/lib/x86_64-linux-gnu/libpcl_recognition.so  
[1.823s] -- looking for PCL_STEREO
[1.824s] -- Found PCL_STEREO: /usr/lib/x86_64-linux-gnu/libpcl_stereo.so  
[1.824s] -- looking for PCL_APPS
[1.825s] -- Found PCL_APPS: /usr/lib/x86_64-linux-gnu/libpcl_apps.so  
[1.826s] -- looking for PCL_IN_HAND_SCANNER
[1.826s] -- Found PCL_IN_HAND_SCANNER: /usr/include/pcl-1.10  
[1.826s] -- looking for PCL_POINT_CLOUD_EDITOR
[1.827s] -- Found PCL_POINT_CLOUD_EDITOR: /usr/include/pcl-1.10  
[1.827s] -- looking for PCL_OUTOFCORE
[1.828s] -- Found PCL_OUTOFCORE: /usr/lib/x86_64-linux-gnu/libpcl_outofcore.so  
[1.828s] -- looking for PCL_PEOPLE
[1.829s] -- Found PCL_PEOPLE: /usr/lib/x86_64-linux-gnu/libpcl_people.so  
[1.830s] -- Found PCL: pcl_common;pcl_kdtree;pcl_octree;pcl_search;pcl_sample_consensus;pcl_filters;pcl_io;pcl_features;pcl_ml;pcl_segmentation;pcl_visualization;pcl_surface;pcl_registration;pcl_keypoints;pcl_tracking;pcl_recognition;pcl_stereo;pcl_apps;pcl_outofcore;pcl_people;/usr/lib/x86_64-linux-gnu/libboost_system.so;/usr/lib/x86_64-linux-gnu/libboost_filesystem.so;/usr/lib/x86_64-linux-gnu/libboost_date_time.so;/usr/lib/x86_64-linux-gnu/libboost_iostreams.so;/usr/lib/x86_64-linux-gnu/libboost_regex.so;optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so;vtkChartsCore;vtkCommonColor;vtkCommonCore;vtksys;vtkCommonDataModel;vtkCommonMath;vtkCommonMisc;vtkCommonSystem;vtkCommonTransforms;vtkCommonExecutionModel;vtkFiltersGeneral;vtkCommonComputationalGeometry;vtkFiltersCore;vtkInfovisCore;vtkFiltersExtraction;vtkFiltersStatistics;vtkImagingFourier;vtkImagingCore;vtkalglib;vtkRenderingContext2D;vtkRenderingCore;vtkFiltersGeometry;vtkFiltersSources;vtkRenderingFreeType;/usr/lib/x86_64-linux-gnu/libfreetype.so;/usr/lib/x86_64-linux-gnu/libz.so;vtkFiltersModeling;vtkImagingSources;vtkInteractionStyle;vtkInteractionWidgets;vtkFiltersHybrid;vtkImagingColor;vtkImagingGeneral;vtkImagingHybrid;vtkIOImage;vtkDICOMParser;vtkmetaio;/usr/lib/x86_64-linux-gnu/libjpeg.so;/usr/lib/x86_64-linux-gnu/libpng.so;/usr/lib/x86_64-linux-gnu/libtiff.so;vtkRenderingAnnotation;vtkRenderingVolume;vtkIOXML;vtkIOCore;vtkIOXMLParser;/usr/lib/x86_64-linux-gnu/libexpat.so;vtkIOGeometry;vtkIOLegacy;vtkIOPLY;vtkRenderingLOD;vtkViewsContext2D;vtkViewsCore;vtkRenderingContextOpenGL2;vtkRenderingOpenGL2;FLANN::FLANN  
[1.836s] CMake Error at /opt/ros/foxy/share/ament_cmake_target_dependencies/cmake/ament_target_dependencies.cmake:77 (message):
**[1.837s]   ament_target_dependencies() the passed package name 'pcl_common' was not
[1.837s]   found before**
[1.837s] Call Stack (most recent call first):
[1.837s]   CMakeLists.txt:32 (ament_target_dependencies)

Snippet from package.xml:

  <depend>rclcpp</depend>
  <depend>std_msgs</depend>
  <depend>sensor_msgs</depend>
  <depend>PCL</depend>
  <depend>pcl_conversions</depend>

Snippet from CMakeLists.txt:

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(pcl_conversions REQUIRED)
find_package(PCL REQUIRED)

include_directories(include ${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

add_library(PclSegmentation src/PclSegmentation.cpp)
ament_target_dependencies(PclSegmentation rclcpp sensor_msgs PCL pcl_conversions ${PCL_LIBRARIES})

Ubuntu 20.04.3 PCL Version 1.10 CMake version 3.16.3

Thank you!

mvieth commented 2 years ago

This seems to be a ROS-specific issue (ament), so please ask in the ROS forums or at the perception_pcl repo

supercrazysam commented 2 months ago

I am trying to build my first program using PCL, however during compilation, ament_target_dependencies() complains that it does not find 'pcl_common'. However in the build logs, it seems like it does actually find it, however it says 'PCL_COMMON' instead. Why does this happen, and what is the workaround?

From the terminal:

Starting >>> pointcloud_detector
--- stderr: pointcloud_detector                         
** WARNING ** io features related to openni will be disabled
** WARNING ** io features related to openni2 will be disabled
** WARNING ** io features related to pcap will be disabled
** WARNING ** io features related to png will be disabled
** WARNING ** io features related to libusb-1.0 will be disabled
** WARNING ** visualization features related to openni will be disabled
** WARNING ** visualization features related to openni2 will be disabled
** WARNING ** apps features related to openni will be disabled
CMake Error at /opt/ros/foxy/share/ament_cmake_target_dependencies/cmake/ament_target_dependencies.cmake:77 (message):
  ament_target_dependencies() the passed package name 'pcl_common' was not
  found before
Call Stack (most recent call first):
  CMakeLists.txt:32 (ament_target_dependencies)

---
Failed   <<< pointcloud_detector [1.87s, exited with code 1]

Summary: 0 packages finished [1.97s]
  1 package failed: pointcloud_detector
  1 package had stderr output: pointcloud_detector

From the streams.log:

[1.802s] -- looking for PCL_COMMON
[1.803s] -- Found PCL_COMMON: /usr/lib/x86_64-linux-gnu/libpcl_common.so  
[1.803s] -- looking for PCL_KDTREE
[1.804s] -- Found PCL_KDTREE: /usr/lib/x86_64-linux-gnu/libpcl_kdtree.so  
[1.804s] -- looking for PCL_OCTREE
[1.805s] -- Found PCL_OCTREE: /usr/lib/x86_64-linux-gnu/libpcl_octree.so  
[1.805s] -- looking for PCL_SEARCH
[1.806s] -- Found PCL_SEARCH: /usr/lib/x86_64-linux-gnu/libpcl_search.so  
[1.806s] -- looking for PCL_SAMPLE_CONSENSUS
[1.807s] -- Found PCL_SAMPLE_CONSENSUS: /usr/lib/x86_64-linux-gnu/libpcl_sample_consensus.so  
[1.808s] -- looking for PCL_FILTERS
[1.808s] -- Found PCL_FILTERS: /usr/lib/x86_64-linux-gnu/libpcl_filters.so  
[1.809s] -- looking for PCL_2D
[1.809s] -- Found PCL_2D: /usr/include/pcl-1.10  
[1.810s] -- looking for PCL_GEOMETRY
[1.810s] -- Found PCL_GEOMETRY: /usr/include/pcl-1.10  
[1.810s] -- looking for PCL_IO
[1.811s] -- Found PCL_IO: /usr/lib/x86_64-linux-gnu/libpcl_io.so  
[1.811s] -- looking for PCL_FEATURES
[1.814s] -- Found PCL_FEATURES: /usr/lib/x86_64-linux-gnu/libpcl_features.so  
[1.814s] -- looking for PCL_ML
[1.815s] -- Found PCL_ML: /usr/lib/x86_64-linux-gnu/libpcl_ml.so  
[1.815s] -- looking for PCL_SEGMENTATION
[1.816s] -- Found PCL_SEGMENTATION: /usr/lib/x86_64-linux-gnu/libpcl_segmentation.so  
[1.816s] -- looking for PCL_VISUALIZATION
[1.817s] -- Found PCL_VISUALIZATION: /usr/lib/x86_64-linux-gnu/libpcl_visualization.so  
[1.817s] -- looking for PCL_SURFACE
[1.818s] -- Found PCL_SURFACE: /usr/lib/x86_64-linux-gnu/libpcl_surface.so  
[1.818s] -- looking for PCL_REGISTRATION
[1.819s] -- Found PCL_REGISTRATION: /usr/lib/x86_64-linux-gnu/libpcl_registration.so  
[1.819s] -- looking for PCL_KEYPOINTS
[1.820s] -- Found PCL_KEYPOINTS: /usr/lib/x86_64-linux-gnu/libpcl_keypoints.so  
[1.820s] -- looking for PCL_TRACKING
[1.821s] -- Found PCL_TRACKING: /usr/lib/x86_64-linux-gnu/libpcl_tracking.so  
[1.822s] -- looking for PCL_RECOGNITION
[1.822s] -- Found PCL_RECOGNITION: /usr/lib/x86_64-linux-gnu/libpcl_recognition.so  
[1.823s] -- looking for PCL_STEREO
[1.824s] -- Found PCL_STEREO: /usr/lib/x86_64-linux-gnu/libpcl_stereo.so  
[1.824s] -- looking for PCL_APPS
[1.825s] -- Found PCL_APPS: /usr/lib/x86_64-linux-gnu/libpcl_apps.so  
[1.826s] -- looking for PCL_IN_HAND_SCANNER
[1.826s] -- Found PCL_IN_HAND_SCANNER: /usr/include/pcl-1.10  
[1.826s] -- looking for PCL_POINT_CLOUD_EDITOR
[1.827s] -- Found PCL_POINT_CLOUD_EDITOR: /usr/include/pcl-1.10  
[1.827s] -- looking for PCL_OUTOFCORE
[1.828s] -- Found PCL_OUTOFCORE: /usr/lib/x86_64-linux-gnu/libpcl_outofcore.so  
[1.828s] -- looking for PCL_PEOPLE
[1.829s] -- Found PCL_PEOPLE: /usr/lib/x86_64-linux-gnu/libpcl_people.so  
[1.830s] -- Found PCL: pcl_common;pcl_kdtree;pcl_octree;pcl_search;pcl_sample_consensus;pcl_filters;pcl_io;pcl_features;pcl_ml;pcl_segmentation;pcl_visualization;pcl_surface;pcl_registration;pcl_keypoints;pcl_tracking;pcl_recognition;pcl_stereo;pcl_apps;pcl_outofcore;pcl_people;/usr/lib/x86_64-linux-gnu/libboost_system.so;/usr/lib/x86_64-linux-gnu/libboost_filesystem.so;/usr/lib/x86_64-linux-gnu/libboost_date_time.so;/usr/lib/x86_64-linux-gnu/libboost_iostreams.so;/usr/lib/x86_64-linux-gnu/libboost_regex.so;optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so;vtkChartsCore;vtkCommonColor;vtkCommonCore;vtksys;vtkCommonDataModel;vtkCommonMath;vtkCommonMisc;vtkCommonSystem;vtkCommonTransforms;vtkCommonExecutionModel;vtkFiltersGeneral;vtkCommonComputationalGeometry;vtkFiltersCore;vtkInfovisCore;vtkFiltersExtraction;vtkFiltersStatistics;vtkImagingFourier;vtkImagingCore;vtkalglib;vtkRenderingContext2D;vtkRenderingCore;vtkFiltersGeometry;vtkFiltersSources;vtkRenderingFreeType;/usr/lib/x86_64-linux-gnu/libfreetype.so;/usr/lib/x86_64-linux-gnu/libz.so;vtkFiltersModeling;vtkImagingSources;vtkInteractionStyle;vtkInteractionWidgets;vtkFiltersHybrid;vtkImagingColor;vtkImagingGeneral;vtkImagingHybrid;vtkIOImage;vtkDICOMParser;vtkmetaio;/usr/lib/x86_64-linux-gnu/libjpeg.so;/usr/lib/x86_64-linux-gnu/libpng.so;/usr/lib/x86_64-linux-gnu/libtiff.so;vtkRenderingAnnotation;vtkRenderingVolume;vtkIOXML;vtkIOCore;vtkIOXMLParser;/usr/lib/x86_64-linux-gnu/libexpat.so;vtkIOGeometry;vtkIOLegacy;vtkIOPLY;vtkRenderingLOD;vtkViewsContext2D;vtkViewsCore;vtkRenderingContextOpenGL2;vtkRenderingOpenGL2;FLANN::FLANN  
[1.836s] CMake Error at /opt/ros/foxy/share/ament_cmake_target_dependencies/cmake/ament_target_dependencies.cmake:77 (message):
**[1.837s]   ament_target_dependencies() the passed package name 'pcl_common' was not
[1.837s]   found before**
[1.837s] Call Stack (most recent call first):
[1.837s]   CMakeLists.txt:32 (ament_target_dependencies)

Snippet from package.xml:

  <depend>rclcpp</depend>
  <depend>std_msgs</depend>
  <depend>sensor_msgs</depend>
  <depend>PCL</depend>
  <depend>pcl_conversions</depend>

Snippet from CMakeLists.txt:

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(pcl_conversions REQUIRED)
find_package(PCL REQUIRED)

include_directories(include ${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

add_library(PclSegmentation src/PclSegmentation.cpp)
ament_target_dependencies(PclSegmentation rclcpp sensor_msgs PCL pcl_conversions ${PCL_LIBRARIES})

Ubuntu 20.04.3 PCL Version 1.10 CMake version 3.16.3

Thank you!

Did you managed to find a solution for this? this seems to be a fairly common problem, please share how you solve it, thank you!!

mvieth commented 2 months ago

So as far as I was able to find out, ${PCL_LIBRARIES} should not go into the ament_target_dependencies call. Correct seems to be:

find_package(PCL REQUIRED)
ament_target_dependencies(my_target PCL)

The alternative is:

...
target_link_libraries(my_target ${PCL_LIBRARIES})

See here: https://docs.ros.org/en/foxy/How-To-Guides/Ament-CMake-Documentation.html According to this, ament_target_dependencies then uses PCL_INCLUDE_DIRS, PCL_LIBRARIES, etc. internally. But I want to emphasize that I know practically nothing about ament, and that ament is a (relatively new) ROS tool, so you should definitely ask somewhere else if you have further problems. This is PCL's tutorial on how to use PCL with CMake. If you have questions about that, feel free to ask.