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

Error when using PCLVisualizer

asked 2012-06-22 08:28:51 -0600

Saphrosit gravatar image

updated 2012-06-22 23:01:08 -0600

I was trying to use PCLVisualizer in a node but when I try to compile (using rosmake) I get as error

/usr/bin/ld: CMakeFiles/viz.dir/src/cluster_visualizer.o: undefined reference to symbol 'vtkSmartPointerBase::operator=(vtkObjectBase*)'
/usr/bin/ld: note: 'vtkSmartPointerBase::operator=(vtkObjectBase*)' is defined in DSO /usr/lib/libvtkCommon.so.5.6 so try adding it to the linker command line
/usr/lib/libvtkCommon.so.5.6: could not read symbols: Invalid operation

Here's the CMakeLists.txt I use

cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

rosbuild_init()

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/include/cluster_extraction )

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
find_package(Eigen REQUIRED)
include_directories(${Eigen_INCLUDE_DIRS})

rosbuild_add_executable(viz src/cluster_visualizer.cpp)

and here's the source code:

#include <iostream>
#include <boost/thread/thread.hpp>
#include <pcl/common/common_headers.h>
#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>

int main () {

    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
    pcl::io::loadPCDFile<pcl::PointXYZ> ("/tmp/pointCloud0.pcd", *cloud);

    boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
    viewer->setBackgroundColor (0, 0, 0);
    viewer->addPointCloud<pcl::PointXYZ> (cloud, "sample cloud");
    viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "sample cloud");
    viewer->addCoordinateSystem (1.0);
    viewer->initCameraParameters ();

    viewer->spin();
}

Any suggestion on how can I fix? I'm using Ubuntu 11.10 with electric

EDIT:

my manifest.xml is

<package>
  <description brief="cluster_extraction">

     cluster_extraction

  </description>
  <author>Manlio</author>
  <license>BSD</license>
  <review status="unreviewed" notes=""/>
  <url>http://ros.org/wiki/cluster_extraction</url>
  <depend package="roscpp"/>
  <depend package="std_msgs"/>
  <depend package="sensor_msgs"/>
  <depend package="pcl"/>
  <depend package="pcl_ros"/>
  <depend package="common_rosdeps" />

  <rosdep name="eigen" />

</package>
edit retag flag offensive close merge delete

Comments

What do you have in your manifest.xml?

Eric Perko gravatar image Eric Perko  ( 2012-06-22 14:28:10 -0600 )edit

@EricPerko I edited the question adding the manifest

Saphrosit gravatar image Saphrosit  ( 2012-06-22 23:01:38 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
7

answered 2012-06-22 11:10:39 -0600

Saphrosit gravatar image

Solved adding

target_link_libraries(viz ${PCL_LIBRARIES} libvtkCommon.so libvtkFiltering.so )

at the end of CMakeLists.txt

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-06-22 08:28:51 -0600

Seen: 4,974 times

Last updated: Jun 22 '12