Compiling with Cmake and PCL
Hi, I am trying to execute the sample programs available in pcl tutorials. I am getting following error while building with catkin_make. Cmakelists and sample code is attaxhed below.
CMake lists:
cmake_minimum_required(VERSION 2.8.3)
project(pcl_ros_tutorial)
find_package(catkin REQUIRED COMPONENTS
pcl_conversions
pcl_ros
roscpp
sensor_msgs
)
find_package(PCL 1.3 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(example src/example.cpp)
target_link_libraries(example ${catkin_LIBRARIES} ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES})
include_directories(
# include
${catkin_INCLUDE_DIRS}
)
example.cpp
#include <ros/ros.h>
// PCL specific includes
#include <sensor_msgs/PointCloud2.h>
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
ros::Publisher pub;
void
cloud_cb (const sensor_msgs::PointCloud2ConstPtr& input)
{
// Create a container for the data.
sensor_msgs::PointCloud2 output;
output = *input;
// Publish the data.
pub.publish (output);
}
int
main (int argc, char** argv)
{
// Initialize ROS
ros::init (argc, argv, "my_pcl_tutorial2");
ros::NodeHandle nh;
// Create a ROS subscriber for the input point cloud
ros::Subscriber sub = nh.subscribe ("input", 1, cloud_cb);
// Create a ROS publisher for the output point cloud
pub = nh.advertise<sensor_msgs::PointCloud2> ("output", 1);
// Spin
ros::spin ();
}
Error:
CMake Error at pcl_ros_tutorial/CMakeLists.txt:34 (target_link_libraries):
Attempt to add link library
"/usr/lib/x86_64-linux-gnu/libboost_serialization.so" to target "example"
which is not built in this directory.
Asked by ARB on 2018-03-10 05:50:50 UTC
Comments
On my system, your CMakeLists.txt and example.cpp build fine as you posted them (Ubuntu 16.04 LTS, ROS Kinetic Kame, all dependencies from the Ubuntu and/or ROS repositories and tested in a new package "pcl_ros_tutorial" in my usual workspace).
Asked by Maarten on 2018-03-10 10:58:15 UTC
@Maarten Did you install pcl seperately in Ubuntu..other than ros dependencies?
Asked by ARB on 2018-03-10 11:07:20 UTC
I installed the ros-kinetic-pcl-ros package, which depends on libpcl-dev and other libpcl packages. I think you have a problem with your workspace and/or package configuration. Does it work in a new workspace and package?
Asked by Maarten on 2018-03-10 11:27:00 UTC