Friday, October 24, 2014

Linking Error: undefined reference to symbol 'vtkCellArray::New()' when using pclVisualizer

While compiling the Correspondence_grouping code from pcl (http://www.pointclouds.org/documentation/tutorials/correspondence_grouping.php ) in my ROS Hydro workspace, I got following linking error:

Linking error:
 Linking CXX executable /home/swagatika/catkin_ws/devel/lib/my_pcl_tutorial/correspondence_grouping
/usr/bin/ld: CMakeFiles/correspondence_grouping.dir/src/correspondence_grouping.cpp.o: undefined reference to symbol 'vtkCellArray::New()'
/usr/bin/ld: note: 'vtkCellArray::New()' is defined in DSO /usr/lib/libvtkFiltering.so.5.8 so try adding it to the linker command line
/usr/lib/libvtkFiltering.so.5.8: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make[2]: *** [/home/swagatika/catkin_ws/devel/lib/my_pcl_tutorial/correspondence_grouping] Error 1
make[1]: *** [my_pcl_tutorial/CMakeFiles/correspondence_grouping.dir/all] Error 2
make: *** [all] Error 2
Invoking "make" failed

Solution:

In  ~/catkin_was/src/my_pcl_tutorial/CMakeLists.txt :

add_executable(correspondence_grouping src/correspondence_grouping.cpp)
target_link_libraries(correspondence_grouping ${catkin_LIBRARIES} ${PCL_LIBRARIES} libvtkCommon.so libvtkFiltering.so )


Ref:

http://www.pointclouds.org/documentation/tutorials/correspondence_grouping.php
http://answers.ros.org/question/37096/error-when-using-pclvisualizer/

2 comments: