Can not link to pcl library.
The following code:
#include <ros/ros.h>
#include <pcl_ros/point_cloud.h>
#include <pcl/point_types.h>
#include <boost/foreach.hpp>
typedef pcl::PointCloud<pcl::PointXYZ> PointCloud;
void callback(const PointCloud::ConstPtr& msg)
{
printf ("Cloud: width = %d, height = %d\n", msg->width, msg->height);
BOOST_FOREACH (const pcl::PointXYZ& pt, msg->points)
printf ("\t(%f, %f, %f)\n", pt.x, pt.y, pt.z);
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "sub_pcl");
ros::NodeHandle nh;
ros::Subscriber sub = nh.subscribe<PointCloud>("points2", 1, callback);
ros::spin();
}
Which is a default tutorial on how to use PCL in ros.
My CMake:
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
find_package(PCL 1.3 REQUIRED COMPONENTS common io)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
target_link_libraries(${PROJECT_NAME} ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES})
Which is the exact configuration recommended on the pcl official website
I still get the following linking error:
CMakeFiles/apsp_manifold.dir/src/apsp_manifold.cpp.o: In function `void pcl::detail::FieldMapper<pcl::PointXYZ>::operator()<pcl::fields::z>()':
/usr/include/pcl-1.7/pcl/conversions.h:106: undefined reference to `pcl::console::print(pcl::console::VERBOSITY_LEVEL, char const*, ...)'
CMakeFiles/apsp_manifold.dir/src/apsp_manifold.cpp.o: In function `void pcl::detail::FieldMapper<pcl::PointXYZ>::operator()<pcl::fields::y>()':
/usr/include/pcl-1.7/pcl/conversions.h:106: undefined reference to `pcl::console::print(pcl::console::VERBOSITY_LEVEL, char const*, ...)'
CMakeFiles/apsp_manifold.dir/src/apsp_manifold.cpp.o: In function `void pcl::detail::FieldMapper<pcl::PointXYZ>::operator()<pcl::fields::x>()':
/usr/include/pcl-1.7/pcl/conversions.h:106: undefined reference to `pcl::console::print(pcl::console::VERBOSITY_LEVEL, char const*, ...)'
What do I have the above described error and how can I remove it?
If you're having trouble linking against PCL, you should probably ask on their mailing list rather than here. This tutorial looks VERY old; I suspect it isn't entirely compatible with the more recent versions of PCL.
It would also be useful to link to the PCL documentation that you're using when you report this: http://pointclouds.org/documentation/...