Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to solve undefined reference to `pcl::search::Search<pcl::PointXYZ>::Search? #1

Open
b2220333 opened this issue Jun 12, 2015 · 9 comments

Comments

@b2220333
Copy link

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 topcl::search::Searchpcl::PointXYZ::Search(std::basic_string<char, std::char_traits, std::allocator > const&, bool)'
CMakeFiles/test_taubin_fitting.dir/src/tests/test_taubin.cpp.o:(.rodata._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[vtable for pcl::search::OrganizedNeighborpcl::PointXYZ]+0x30): undefined reference to pcl::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 topcl::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 topcl::search::Searchpcl::PointXYZ::Search(std::basic_string<char, std::char_traits, std::allocator > const&, bool)'
CMakeFiles/hands_test.dir/src/tests/hands_test.cpp.o:(.rodata._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[vtable for pcl::search::OrganizedNeighborpcl::PointXYZ]+0x30): undefined reference to pcl::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 topcl::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~

@atenpas
Copy link
Owner

atenpas commented Jun 13, 2015

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?

@b2220333
Copy link
Author

I do not remember I install the version of PCL without ROS or not.
What should I do?

@atenpas
Copy link
Owner

atenpas commented Jun 13, 2015

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.

@b2220333
Copy link
Author

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 topcl::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 topcl::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 topcl::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 topcl::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 topcl::PCLBasepcl::PointXYZ::setIndices(boost::shared_ptr<std::vector<int, std::allocator > > const&)'
/home/sam/code/ros_hydro/devel/lib/libhandle_search.so: undefined reference to pcl::visualization::PointCloudGeometryHandlerXYZ<pcl::PointNormal>::getGeometry(vtkSmartPointer<vtkPoints>&) const' /home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference topcl::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 topcl::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 topcl::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 topcl::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 topcl::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 topcl::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 topcl::PCLBasepcl::PointXYZ::setIndices(boost::shared_ptr<std::vector<int, std::allocator > > const&)'
/home/sam/code/ros_hydro/devel/lib/libhandle_search.so: undefined reference to pcl::visualization::PointCloudGeometryHandlerXYZ<pcl::PointNormal>::getGeometry(vtkSmartPointer<vtkPoints>&) const' /home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference topcl::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 topcl::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 topcl::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 topcl::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 topcl::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 topcl::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 topcl::PCLBasepcl::PointXYZ::setIndices(boost::shared_ptr<std::vector<int, std::allocator > > const&)'
/home/sam/code/ros_hydro/devel/lib/libhandle_search.so: undefined reference to pcl::visualization::PointCloudGeometryHandlerXYZ<pcl::PointNormal>::getGeometry(vtkSmartPointer<vtkPoints>&) const' /home/sam/code/ros_hydro/devel/lib/liblocalization.so: undefined reference topcl::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 topcl::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 topcl::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 topcl::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$

@adityadhawale
Copy link

Any solutions yet?

@ydawei
Copy link

ydawei commented Feb 6, 2017

My solution was cmake clean and rebuild. Don't understand why.

@qixuxiang
Copy link

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})

@UditSinghParihar
Copy link

UditSinghParihar commented Sep 13, 2018

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})

@PoplarTang
Copy link

Including <pcl/search/impl/search.hpp> on top of your code. Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants