Linker error: Normal calculation [closed]
I get a linker error while I try to build following code. It seems code is ok. Linker error msg. is given below: error LNK2001: unresolved external symbol "protected: virtual void __cdecl pcl::NormalEstimation<struct pcl::pointxyz,struct="" pcl::normal="">::computeFeature(class pcl::PointCloud<struct pcl::normal=""> &)" (?computeFeature@?$NormalEstimation@UPointXYZ@pcl@@UNormal@2@@pcl@@MEAAXAEAV?$PointCloud@UNormal@pcl@@@2@@Z)
How can I resolve this?
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/features/normal_3d.h>
int main (int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZ> cloud;
// Fill in the cloud data
cloud.width = 5;
cloud.height = 1;
cloud.is_dense = false;
cloud.points.resize (cloud.width * cloud.height);
for (size_t i = 0; i < cloud.points.size (); ++i)
{
cloud.points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
cloud.points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
cloud.points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
}
pcl::io::savePCDFileASCII ("test_pcd.pcd", cloud);
std::cerr << "Saved " << cloud.points.size () << " data points to test_pcd.pcd." << std::endl;
for (size_t i = 0; i < cloud.points.size (); ++i)
std::cerr << " " << cloud.points[i].x << " " << cloud.points[i].y << " " << cloud.points[i].z << std::endl;
///////// Normal Calculation Start/////////////////
// Create the normal estimation class, and pass the input dataset to it
pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne;
ne.setInputCloud (cloud.makeShared());
// Create an empty kdtree representation, and pass it to the normal estimation object.
// Its content will be filled inside the object, based on the given input dataset (as no other search surface is given).
pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ> ());
ne.setSearchMethod (tree);
// Output datasets
pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>);
// Use all neighbors in a sphere of radius 3cm
ne.setRadiusSearch (0.03);
// Compute the features
ne.compute (*cloud_normals);
std::cerr << "Normal cloud size " << cloud_normals->points.size()<< std::endl;
for (size_t i = 0; i < cloud_normals->points.size(); ++i)
std::cerr << " " << cloud_normals->points[i].normal_x << " " << cloud_normals->points[i].normal_y << " " << cloud_normals->points[i].normal_z << std::endl;
///////// Normal Calculation End//////////////////
return (0);
}
What does your CMakeLists.txt file look like?
Might be related to http://answers.ros.org/question/19649...