PointCloudLibrary / pcl

Point Cloud Library (PCL)

Home Page:https://pointclouds.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I am getting pcl::PCLBase<pcl::PointXYZIR> and undefined reference to `pcl::KdTreeFLANN<pcl::PointXYZIR, flann::L2_Simple<float> >::KdTreeFLANN(bool) while library linking

anamadheya opened this issue · comments

I am using ROS Noetic to build some calibration code and I am facing

undefined reference to pcl::PCLBase<pcl::PointXYZIR>::deinitCompute()' undefined reference to pcl::PCLBasepcl::PointXYZIR::initCompute()'
undefined reference to pcl::PCLBase<pcl::PointXYZIR>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > const> const&)' pcl::KdTreeFLANN<pcl::PointXYZIR, flann::L2_Simple<float> >::KdTreeFLANN(bool)' undefined reference to pcl::PCLBasepcl::PointXYZIR::setInputCloud(boost::shared_ptr<pcl::PointCloudpcl::PointXYZIR const> const&)'
/catkin_ws/devel/.private/cam_lidar_calibration/lib/libcam_lidar_calibration.so: undefined reference to pcl::KdTreeFLANN<pcl::PointXYZIR, flann::L2_Simple<float> >::setSortedResults(bool)' catkin_ws/devel/.private/cam_lidar_calibration/lib/libcam_lidar_calibration.so: undefined reference to pcl::PCLBasepcl::PointXYZIR::setIndices(unsigned long, unsigned long, unsigned long, unsigned long)'
catkin_ws/devel/.private/cam_lidar_calibration/lib/libcam_lidar_calibration.so: undefined reference to pcl::PCLBase<pcl::PointXYZIR>::setIndices(boost::shared_ptr<pcl::PointIndices const> const&)' catkin_ws/devel/.private/cam_lidar_calibration/lib/libcam_lidar_calibration.so: undefined reference to pcl::PCLBasepcl::PointXYZIR::PCLBase()'
catkin_ws/devel/.private/cam_lidar_calibration/lib/libcam_lidar_calibration.so: undefined reference to `pcl::PCLBasepcl::PointXYZIR::setIndices(boost::shared_ptr<std::vector<int, std::allocator > > const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/feature_extraction_node.dir/build.make:303: catkin_ws/devel/.private/cam_lidar_calibration/lib/cam_lidar_calibration/feature_extraction_node] Error 1
make[1]: *** [CMakeFiles/Makefile2:3731: CMakeFiles/feature_extraction_node.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

My cmakelist looks something like this
find_package(PCL 1.9 REQUIRED COMPONENTS common)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
target_link_libraries(cam_lidar_calibration
${catkin_LIBRARIES}
${OpenCV_LIBS}
${Eigen_LIBRARIES}
${PCL_COMMON_LIBRARIES}
Qt5::Widgets
)

I am using ROS Noetic to build some calibration code and I am facing

My cmakelist looks something like this find_package(PCL 1.9 REQUIRED COMPONENTS common) target_link_libraries(cam_lidar_calibration ${catkin_LIBRARIES} ${OpenCV_LIBS} ${Eigen_LIBRARIES} ${PCL_COMMON_LIBRARIES} Qt5::Widgets )

If this is how it actually looks, you only specify to use the common submodule of PCL. Hence you don't link to the KDtree submodule, which you are using.

Either omit the COMPONENTS part and find all modules and link to all of them, ie PCL_LIBRARIES - or add all that you use, ie common, kdtree, search, features etc.

@larshg I changed as you mentioned it looks something like this now
find_package(PCL 1.9 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
target_link_libraries(cam_lidar_calibration
${catkin_LIBRARIES}
${OpenCV_LIBS}
${Eigen_LIBRARIES}
${PCL_LIBRARIES}
Qt5::Widgets
)
message("PCL : ${PCL_LIBRARIES}")

The output of message : 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_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_thread.so;-lpthread;/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_serialization.so;/usr/lib/x86_64-linux-gnu/libboost_chrono.so;/usr/lib/x86_64-linux-gnu/libboost_atomic.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;lz4;flann;flann_cpp;vtkChartsCore;vtkCommonColor;vtkCommonCore;vtksys;vtkCommonDataModel;vtkCommonMath;vtkCommonMisc;vtkCommonSystem;vtkCommonTransforms;vtkCommonExecutionModel;vtkFiltersGeneral;vtkCommonComputationalGeometry;vtkFiltersCore;vtkInfovisCore;vtkFiltersExtraction;vtkFiltersStatistics;vtkImagingFourier;vtkImagingCore;vtkalglib;vtkRenderingContext2D;vtkRenderingCore;vtkFiltersGeometry;vtkFiltersSources;vtkRenderingFreeType;vtkfreetype;vtkzlib;vtkDICOMParser;vtkDomainsChemistry;vtkIOLegacy;vtkIOCore;vtkIOXMLParser;vtkexpat;vtkDomainsChemistryOpenGL2;vtkRenderingOpenGL2;vtkIOImage;vtkmetaio;vtkjpeg;vtkpng;vtktiff;vtkglew;vtkFiltersAMR;vtkIOXML;vtkParallelCore;vtkFiltersFlowPaths;vtkFiltersGeneric;vtkFiltersHybrid;vtkImagingSources;vtkFiltersHyperTree;vtkFiltersImaging;vtkImagingGeneral;vtkFiltersModeling;vtkFiltersParallel;vtkFiltersParallelImaging;vtkFiltersPoints;vtkFiltersProgrammable;vtkFiltersSMP;vtkFiltersSelection;vtkFiltersTexture;vtkFiltersVerdict;verdict;vtkGUISupportQt;vtkInteractionStyle;vtkGUISupportQtSQL;vtkIOSQL;vtksqlite;vtkGeovisCore;vtkInfovisLayout;vtkImagingHybrid;vtkInteractionWidgets;vtkImagingColor;vtkRenderingAnnotation;vtkRenderingVolume;vtkViewsCore;vtkproj4;vtkIOAMR;vtkhdf5_hl;vtkhdf5;vtkIOEnSight;vtkIOExodus;vtkexoIIc;vtkNetCDF;vtkNetCDF_cxx;vtkIOExport;vtkRenderingGL2PSOpenGL2;vtkgl2ps;vtkIOGeometry;vtkIOImport;vtkIOInfovis;vtklibxml2;vtkIOLSDyna;vtkIOMINC;vtkIOMovie;vtkoggtheora;vtkIONetCDF;vtkIOPLY;vtkIOParallel;vtkjsoncpp;vtkIOParallelXML;vtkIOTecplotTable;vtkIOVideo;vtkImagingMath;vtkImagingMorphological;vtkImagingStatistics;vtkImagingStencil;vtkInteractionImage;vtkRenderingContextOpenGL2;vtkRenderingImage;vtkRenderingLOD;vtkRenderingLabel;vtkRenderingQt;vtkRenderingVolumeOpenGL2;vtkViewsContext2D;vtkViewsInfovis;vtkViewsQt

Still I am getting the same error

/usr/bin/ld: /home/adithya/catkin_ws/devel/.private/cam_lidar_calibration/lib/libcam_lidar_calibration.so: undefined reference to pcl::PCLBase<pcl::PointXYZIR>::deinitCompute()' /usr/bin/ld: /home/adithya/catkin_ws/devel/.private/cam_lidar_calibration/lib/libcam_lidar_calibration.so: undefined reference to pcl::PCLBasepcl::PointXYZIR::initCompute()'
/usr/bin/ld: /home/adithya/catkin_ws/devel/.private/cam_lidar_calibration/lib/libcam_lidar_calibration.so: undefined reference to pcl::PCLBase<pcl::PointXYZIR>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > const> const&)' /usr/bin/ld: /home/adithya/catkin_ws/devel/.private/cam_lidar_calibration/lib/libcam_lidar_calibration.so: undefined reference to pcl::KdTreeFLANN<pcl::PointXYZIR, flann::L2_Simple >::KdTreeFLANN(bool)'
/usr/bin/ld: /home/adithya/catkin_ws/devel/.private/cam_lidar_calibration/lib/libcam_lidar_calibration.so: undefined reference to pcl::PCLBase<pcl::PointXYZIR>::setInputCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZIR> const> const&)' /usr/bin/ld: /home/adithya/catkin_ws/devel/.private/cam_lidar_calibration/lib/libcam_lidar_calibration.so: undefined reference to pcl::KdTreeFLANN<pcl::PointXYZIR, flann::L2_Simple >::setSortedResults(bool)'
/usr/bin/ld: /home/adithya/catkin_ws/devel/.private/cam_lidar_calibration/lib/libcam_lidar_calibration.so: undefined reference to pcl::PCLBase<pcl::PointXYZIR>::setIndices(unsigned long, unsigned long, unsigned long, unsigned long)' /usr/bin/ld: /home/adithya/catkin_ws/devel/.private/cam_lidar_calibration/lib/libcam_lidar_calibration.so: undefined reference to pcl::PCLBasepcl::PointXYZIR::setIndices(boost::shared_ptr<pcl::PointIndices const> const&)'
/usr/bin/ld: /home/adithya/catkin_ws/devel/.private/cam_lidar_calibration/lib/libcam_lidar_calibration.so: undefined reference to pcl::PCLBase<pcl::PointXYZIR>::PCLBase()' /usr/bin/ld: /home/adithya/catkin_ws/devel/.private/cam_lidar_calibration/lib/libcam_lidar_calibration.so: undefined reference to pcl::PCLBasepcl::PointXYZIR::setIndices(boost::shared_ptr<std::vector<int, std::allocator > > const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/feature_extraction_node.dir/build.make:572: /home/adithya/catkin_ws/devel/.private/cam_lidar_calibration/lib/cam_lidar_calibration/feature_extraction_node] Error 1
make[1]: *** [CMakeFiles/Makefile2:3731: CMakeFiles/feature_extraction_node.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

I have cleaned the build
catkin clean and built it again . Still the same

@anamadheya Since PointXYZIR is not a PCL native point type (not listed in common/include/pcl/point_types.h), you will have to use PCL_NO_PRECOMPILE, see https://pcl.readthedocs.io/projects/tutorials/en/master/adding_custom_ptype.html

@mvieth It worked , Thanks for the support . Saved my day !