0
votes

I am new with pcl library and I have problems linking the example project.

I have download the all-in-one installer to vsmc2010 x64 (the OpenNI library doesn’t install successful and repeat the installation without this)

In a Visual Studio 2010 project:

  1. I have create a new win32 console project
  2. Into a properties:
    • C++->General-> include boost, eigen and pcl include directories
    • Linker->General->additional libraries-> pcl lib folder

#include <iostream>
#include <pcl/point_types.h>
#include <pcl/filters/passthrough.h>

int main (int argc, char** argv)
{
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered (new pcl::PointCloud<pcl::PointXYZ>);

  // Fill in the cloud data
  cloud->width  = 5;
  cloud->height = 1;
  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);
  }

  std::cerr << "Cloud before filtering: " << 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;

  // Create the filtering object
  pcl::PassThrough<pcl::PointXYZ> pass;
  /*pass.setInputCloud (cloud);
  pass.setFilterFieldName ("z");
  pass.setFilterLimits (0.0, 1.0);
  //pass.setFilterLimitsNegative (true);
  pass.filter (*cloud_filtered);

  std::cerr << "Cloud after filtering: " << std::endl;
  for (size_t i = 0; i < cloud_filtered->points.size (); ++i)
    std::cerr << "    " << cloud_filtered->points[i].x << " " 
                        << cloud_filtered->points[i].y << " " 
                        << cloud_filtered->points[i].z << std::endl;*/

  return (0);
}

But I have linker errors:

Error   8   error LNK2019: símbolo externo "protected: void __cdecl pcl::PassThrough<struct pcl::PointXYZ>::applyFilterIndices(class std::vector<int,class std::allocator<int> > &)" (?applyFilterIndices@?$PassThrough@UPointXYZ@pcl@@@pcl@@IEAAXAEAV?$vector@HV?$allocator@H@std@@@std@@@Z) sin resolver al que se hace referencia en la función "protected: virtual void __cdecl pcl::PassThrough<struct pcl::PointXYZ>::applyFilter(class std::vector<int,class std::allocator<int> > &)" (?applyFilter@?$PassThrough@UPointXYZ@pcl@@@pcl@@MEAAXAEAV?$vector@HV?$allocator@H@std@@@std@@@Z) 

Any one could help me?

1
It is a template method, they don't have external linkage. Looks to me like the "pcl" library programmer fumbled this. Not sure what kind of library that might be, it certainly is not a "printer control language". Use the Point Cloud Library mailing list, I guess. - Hans Passant
If you're just starting, consider using CMake. It will be much easier as it will include everything by itself. If you have never used CMake before, don't hesitate to ask further questions. UPD: but concerning your error, it seems like VS doesn't see implemenatation in .lib file or cannot find lib file at all. - Jun Murakami

1 Answers

0
votes

I recommend that you use CMake to create your PCL project. Down below I'll link a guide to the latest PCL 1.8.0 release with the all-in-one installer, note that it works with either Visual Studio 2013 or 2015. Be sure to use the provided CMakeLists.txt from this website if you choose to follow this guide, I initially used another one that gave me some linker issues.

CMake: https://cmake.org/ PCL 1.8.0: http://unanancyowen.com/en/pcl18/

Hope this helps!