agile_grasp
agile_grasp copied to clipboard
How to solve undefined reference to `pcl::search::Search<pcl::PointXYZ>::Search?
I use ubuntu 12.04 64bits with ROS Hydro.
I run: sudo apt-get install liblapack-dev git clone https://github.com/atenpas/agile_grasp.git -b hydro rospack profile
when I catkin_make, it shows errors:
...
[ 74%] Built target handle_search
Scanning dependencies of target localization
CMakeFiles/test_taubin_fitting.dir/src/tests/test_taubin.cpp.o: In function main': test_taubin.cpp:(.text.startup+0x16b): undefined reference to
pcl::search::Searchpcl::PointXYZ::Search(std::basic_string<char, std::char_traitspcl::search::Search<pcl::PointXYZ>::getSortedResults()' CMakeFiles/test_taubin_fitting.dir/src/tests/test_taubin.cpp.o:(.rodata._ZTVN3pcl6search6SearchINS_8PointXYZEEE[vtable for pcl::search::Search<pcl::PointXYZ>]+0x30): undefined reference to
pcl::search::Searchpcl::PointXYZ::getSortedResults()'
collect2: ld returned 1 exit status
make[2]: *** [/home/ira/code/ros_hydro/devel/lib/agile_grasp/test_taubin_fitting] Error 1
make[1]: *** [download/agile_grasp/CMakeFiles/test_taubin_fitting.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
CMakeFiles/hands_test.dir/src/tests/hands_test.cpp.o: In function main': hands_test.cpp:(.text.startup+0x16b): undefined reference to
pcl::search::Searchpcl::PointXYZ::Search(std::basic_string<char, std::char_traitspcl::search::Search<pcl::PointXYZ>::getSortedResults()' CMakeFiles/hands_test.dir/src/tests/hands_test.cpp.o:(.rodata._ZTVN3pcl6search6SearchINS_8PointXYZEEE[vtable for pcl::search::Search<pcl::PointXYZ>]+0x30): undefined reference to
pcl::search::Searchpcl::PointXYZ::getSortedResults()'
collect2: ld returned 1 exit status
make[2]: *** [/home/ira/code/ros_hydro/devel/lib/agile_grasp/hands_test] Error 1
make[1]: *** [download/agile_grasp/CMakeFiles/hands_test.dir/all] Error 2
[ 76%] Building CXX object download/agile_grasp/CMakeFiles/localization.dir/src/agile_grasp/localization.cpp.o
Linking CXX shared library /home/ira/code/ros_hydro/devel/lib/liblocalization.so
[ 76%] Built target localization
make: *** [all] Error 2
Invoking "make" failed
ira@ira:~/code/ros_hydro$
It's looks like the PCL linking problem. How to solve it? Thank you~
I'm not sure what the problem is because test_taubin.cpp has an include for pcl/search/organized.h, and the file is linked to PCL libraries (https://github.com/atenpas/agile_grasp/blob/hydro/CMakeLists.txt#L142).
Do you have different versions of PCL installed?
I do not remember I install the version of PCL without ROS or not. What should I do?
You could remove all lines related to test_taubin.cpp from CMakeLists.txt. It's just a test file - it's not required to run the ROS nodes.
After I comment: #add_executable(test_taubin_fitting src/tests/test_taubin.cpp) #target_link_libraries(test_taubin_fitting quadric ${PCL_LIBRARIES})
And I compile again, it shows:
[ 83%] Built target hand_search
Linking CXX executable /home/sam/code/ros_hydro/devel/lib/agile_grasp/hands_test
[ 85%] Built target handle_search
[ 87%] Built target localization
Linking CXX executable /home/sam/code/ros_hydro/devel/lib/agile_grasp/antipodal_test
Linking CXX executable /home/sam/code/ros_hydro/devel/lib/agile_grasp/learning_test
[ 88%] Built target grasp_localizer
Linking CXX executable /home/sam/code/ros_hydro/devel/lib/agile_grasp/test_local_axes
CMakeFiles/hands_test.dir/src/tests/hands_test.cpp.o: In function main': hands_test.cpp:(.text.startup+0x157): undefined reference to
pcl::search::Searchpcl::PointXYZ::Search(std::string const&, bool)'
CMakeFiles/hands_test.dir/src/tests/hands_test.cpp.o:(.rodata._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x30): undefined reference to pcl::search::Search<pcl::PointXYZ>::getSortedResults()' CMakeFiles/hands_test.dir/src/tests/hands_test.cpp.o:(.rodata._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x30): undefined reference to
pcl::search::Searchpcl::PointXYZ::getSortedResults()'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/sam/code/ros_hydro/devel/lib/agile_grasp/hands_test] Error 1
make[1]: *** [download/agile_grasp/CMakeFiles/hands_test.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
/home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to pcl::PCLBase<pcl::PointXYZ>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > const> const&)' /home/sam/code/ros_hydro/devel/lib/libhandle_search.so: undefined reference to
pcl::visualization::PCLVisualizer::wasStopped() const'
/home/sam/code/ros_hydro/devel/lib/libhandle_search.so: undefined reference to pcl::visualization::PCLVisualizer::close()' /home/sam/code/ros_hydro/devel/lib/libhandle_search.so: undefined reference to
pcl::visualization::PointCloudGeometryHandlerXYZpcl::PointNormal::PointCloudGeometryHandlerXYZ(boost::shared_ptrpcl::PointCloud<pcl::PointNormal const> const&)'
/home/sam/code/ros_hydro/devel/lib/libhandle_search.so: undefined reference to pcl::visualization::PCLVisualizer::setPosition(int, int)' /home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to
pcl::PCLBasepcl::PointXYZ::setIndices(boost::shared_ptr<std::vector<int, std::allocatorpcl::visualization::PointCloudGeometryHandlerXYZ<pcl::PointNormal>::getGeometry(vtkSmartPointer<vtkPoints>&) const' /home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to
pcl::PCDReader::read(std::string const&, pcl::PCLPointCloud2&, Eigen::Matrix<float, 4, 1, 0, 4, 1>&, Eigen::Quaternion<float, 0>&, int&, int)'
/home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to pcl::PCLBase<pcl::PointXYZ>::setIndices(boost::shared_ptr<pcl::PointIndices const> const&)' /home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to
pcl::PCLBasepcl::PointXYZ::PCLBase()'
/home/sam/code/ros_hydro/devel/lib/libhandle_search.so: undefined reference to pcl::visualization::PCLVisualizer::setSize(int, int)' /home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to
pcl::SACSegmentationpcl::PointXYZ::segment(pcl::PointIndices&, pcl::ModelCoefficients&)'
/home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to pcl::PCLBase<pcl::PointXYZ>::setIndices(unsigned long, unsigned long, unsigned long, unsigned long)' /home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to
pcl::PCLBasepcl::PointXYZ::deinitCompute()'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/sam/code/ros_hydro/devel/lib/agile_grasp/test_local_axes] Error 1
make[1]: *** [download/agile_grasp/CMakeFiles/test_local_axes.dir/all] Error 2
/home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to pcl::PCLBase<pcl::PointXYZ>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > const> const&)' /home/sam/code/ros_hydro/devel/lib/libhandle_search.so: undefined reference to
pcl::visualization::PCLVisualizer::wasStopped() const'
/home/sam/code/ros_hydro/devel/lib/libhandle_search.so: undefined reference to pcl::visualization::PCLVisualizer::close()' /home/sam/code/ros_hydro/devel/lib/libhandle_search.so: undefined reference to
pcl::visualization::PointCloudGeometryHandlerXYZpcl::PointNormal::PointCloudGeometryHandlerXYZ(boost::shared_ptrpcl::PointCloud<pcl::PointNormal const> const&)'
/home/sam/code/ros_hydro/devel/lib/libhandle_search.so: undefined reference to pcl::visualization::PCLVisualizer::setPosition(int, int)' /home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to
pcl::PCLBasepcl::PointXYZ::setIndices(boost::shared_ptr<std::vector<int, std::allocatorpcl::visualization::PointCloudGeometryHandlerXYZ<pcl::PointNormal>::getGeometry(vtkSmartPointer<vtkPoints>&) const' /home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to
pcl::PCDReader::read(std::string const&, pcl::PCLPointCloud2&, Eigen::Matrix<float, 4, 1, 0, 4, 1>&, Eigen::Quaternion<float, 0>&, int&, int)'
/home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to pcl::PCLBase<pcl::PointXYZ>::setIndices(boost::shared_ptr<pcl::PointIndices const> const&)' /home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to
pcl::PCLBasepcl::PointXYZ::PCLBase()'
/home/sam/code/ros_hydro/devel/lib/libhandle_search.so: undefined reference to pcl::visualization::PCLVisualizer::setSize(int, int)' /home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to
pcl::SACSegmentationpcl::PointXYZ::segment(pcl::PointIndices&, pcl::ModelCoefficients&)'
/home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to pcl::PCLBase<pcl::PointXYZ>::setIndices(unsigned long, unsigned long, unsigned long, unsigned long)' /home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to
pcl::PCLBasepcl::PointXYZ::deinitCompute()'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/sam/code/ros_hydro/devel/lib/agile_grasp/antipodal_test] Error 1
make[1]: *** [download/agile_grasp/CMakeFiles/antipodal_test.dir/all] Error 2
/home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to pcl::PCLBase<pcl::PointXYZ>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > const> const&)' /home/sam/code/ros_hydro/devel/lib/libhandle_search.so: undefined reference to
pcl::visualization::PCLVisualizer::wasStopped() const'
/home/sam/code/ros_hydro/devel/lib/libhandle_search.so: undefined reference to pcl::visualization::PCLVisualizer::close()' /home/sam/code/ros_hydro/devel/lib/libhandle_search.so: undefined reference to
pcl::visualization::PointCloudGeometryHandlerXYZpcl::PointNormal::PointCloudGeometryHandlerXYZ(boost::shared_ptrpcl::PointCloud<pcl::PointNormal const> const&)'
/home/sam/code/ros_hydro/devel/lib/libhandle_search.so: undefined reference to pcl::visualization::PCLVisualizer::setPosition(int, int)' /home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to
pcl::PCLBasepcl::PointXYZ::setIndices(boost::shared_ptr<std::vector<int, std::allocatorpcl::visualization::PointCloudGeometryHandlerXYZ<pcl::PointNormal>::getGeometry(vtkSmartPointer<vtkPoints>&) const' /home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to
pcl::PCDReader::read(std::string const&, pcl::PCLPointCloud2&, Eigen::Matrix<float, 4, 1, 0, 4, 1>&, Eigen::Quaternion<float, 0>&, int&, int)'
/home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to pcl::PCLBase<pcl::PointXYZ>::setIndices(boost::shared_ptr<pcl::PointIndices const> const&)' /home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to
pcl::PCLBasepcl::PointXYZ::PCLBase()'
/home/sam/code/ros_hydro/devel/lib/libhandle_search.so: undefined reference to pcl::visualization::PCLVisualizer::setSize(int, int)' /home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to
pcl::SACSegmentationpcl::PointXYZ::segment(pcl::PointIndices&, pcl::ModelCoefficients&)'
/home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to pcl::PCLBase<pcl::PointXYZ>::setIndices(unsigned long, unsigned long, unsigned long, unsigned long)' /home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference to
pcl::PCLBasepcl::PointXYZ::deinitCompute()'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/sam/code/ros_hydro/devel/lib/agile_grasp/learning_test] Error 1
make[1]: *** [download/agile_grasp/CMakeFiles/learning_test.dir/all] Error 2
make: *** [all] Error 2
Invoking "make" failed
sam@sam:~/code/ros_hydro$
Any solutions yet?
My solution was cmake clean and rebuild. Don't understand why.
add this to CMakeLists.txt
find_package (PCL 1.8 REQUIRED)
set(PCL_INCLUDE_DIRS /usr/local/include/pcl-1.8) #指定pcl1.8路径
include_directories( ... ${PCL_INCLUDE_DIRS})
target_link_libraries( ... ${PCL_LIBRARIES})
My problem is solved after qixuxiang suggestions, Now CMakeLists.txt look like:
cmake_minimum_required (VERSION 3.5.1)
project (icp)
find_package (PCL 1.7 REQUIRED)
set(PCL_INCLUDE_DIRS /usr/local/include/pcl-1.7 /usr/include/eigen3/)
include_directories(${PCL_INCLUDE_DIRS})
add_executable(pcl_test pcl_test.cpp)
target_link_libraries(pcl_test ${PCL_LIBRARIES})
Including <pcl/search/impl/search.hpp>
on top of your code. Good luck!