ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

error: undefined reference to `pcl::visualization::PCLVisualizer::createActorFromVTKDataSet()'

asked 2020-11-14 06:16:09 -0500

bgwqy gravatar image

im using ros noetic and pcl1.9.1 on ubuntu 20.04, i added below codes and catkin_make:

    pcl::PointCloud<pcl::PointXYZI>::Ptr to_show(new pcl::PointCloud<pcl::PointXYZI>);
    boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer(new pcl::visualization::PCLVisualizer("viewer"));
    viewer->setBackgroundColor (0, 0, 0);
    viewer->addCoordinateSystem (1.0f);
    pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZI> h1(to_show, 255, 0, 0);
    viewer->addPointCloud(to_show, h1, "h1");
    while(!viewer->wasStopped()){
        viewer->spinOnce(100);
    }

and then occured an error:

undefined reference to `pcl::visualization::PCLVisualizer::createActorFromVTKDataSet(vtkSmartPointer<vtkDataSet> const&, vtkSmartPointer<vtkLODActor>&, bool)'

i have already included all c++ source files releated i can find to my code, but it still cant build successfully. Does anybody else has the same issue? Can someone tell me which c++ file the implementation of "createActorFromVTKDataSet()" locate at?

Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2020-12-18 14:53:18 -0500

gerkey gravatar image

My guess is that you're not linking against pcl_visualization. Here's a minimal program containing your code, along with a cmake recipe that compiles and links successfully for me under Kinetic on Ubuntu 18.04:

foo.cc:

#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/visualization/pcl_visualizer.h>

int main(void)
{
  pcl::PointCloud<pcl::PointXYZI>::Ptr to_show(new pcl::PointCloud<pcl::PointXYZI>);
  boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer(new pcl::visualization::PCLVisualizer("viewer"));
  viewer->setBackgroundColor (0, 0, 0);
  viewer->addCoordinateSystem (1.0f);
  pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZI> h1(to_show, 255, 0, 0);
  viewer->addPointCloud(to_show, h1, "h1");
  while(!viewer->wasStopped()){
    viewer->spinOnce(100);
  }
}

CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)
project(foo)
find_package(catkin REQUIRED COMPONENTS
  pcl_ros
)
include_directories(
  ${catkin_INCLUDE_DIRS}
)
add_executable(foo foo.cc)
target_link_libraries(foo
  ${catkin_LIBRARIES}
  pcl_visualization
)
edit flag offensive delete link more

Comments

With Ubuntu 20.04 and ROS Noetic Ninjemys, this solved the problem for me when I added "pcl_visaulization" in CMakelists.txt in target_link_libraries

Petro gravatar image Petro  ( 2021-06-10 23:58:59 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2020-11-14 06:16:09 -0500

Seen: 3,349 times

Last updated: Dec 18 '20