0

I'm trying to load a pcd file using pcl library, I do and show it using cloud viewer but I'm trying to use PCLVisualizer. When I use addPointCloud function I have an error:

Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol "public: static class vtkMatrix4x4 * __cdecl vtkMatrix4x4::New(void)" (?New@vtkMatrix4x4@@SAPEAV1@XZ) referenced in function "public: static class vtkSmartPointer __cdecl vtkSmartPointer::New(void)" (?New@?$vtkSmartPointer@VvtkMatrix4x4@@@@SA?AV1@XZ) SamplePCL C:\Users\Nima_S_H\Documents\Visual Studio 2015\Projects\SamplePCL\SamplePCL\Source.obj 1

My codes:

#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_WARNINGS
#define _HAS_ITERATOR_DEBUGGING  0
#define _ITERATOR_DEBUG_LEVEL  0

#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>
void main()
{

typedef pcl::PointXYZRGB PTYPE;
pcl::PointCloud<PTYPE>::Ptr myCloudPtr(new pcl::PointCloud<PTYPE>);
if (pcl::io::loadPCDFile("e:/myCloudASCII.pcd", *myCloudPtr) == -1)
{
    PCL_ERROR("Could not read PCD file.");
    return;
}
pcl::visualization::PCLVisualizer viz;
viz.addPointCloud(myCloudPtr);
viz.spin();


}
Nima.S-H
  • 777
  • 1
  • 9
  • 19
  • This snippet will not compile as such for me. You have void main function. If I change that to int ( and the return value too) it compiles and runs with no problem - although you see nothing – Rooscannon Apr 16 '18 at 07:32

1 Answers1

0

this works for me. Edit: actually it works even without the spinOnce . just use spin..

#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_WARNINGS
#define _HAS_ITERATOR_DEBUGGING  0
#define _ITERATOR_DEBUG_LEVEL  0

#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>
int  main()
{

typedef pcl::PointXYZ PTYPE;
pcl::PointCloud<PTYPE>::Ptr myCloudPtr(new pcl::PointCloud<PTYPE>);
if (pcl::io::loadPCDFile("test.pcd", *myCloudPtr) == -1)
{
    PCL_ERROR("Could not read PCD file.");
    return 0;
}
pcl::visualization::PCLVisualizer viz;
viz.addPointCloud(myCloudPtr);
    while (!viz.wasStopped ())
    {
      viz.spinOnce (100);
    }

return 1;
}
Rooscannon
  • 316
  • 2
  • 7
  • Thanks,but unfortunately not worked for me, I have Link2019 error, that's about linker. I use PCL 1.8.0 all in one, I don't why show me this error, which version of pcl do you use? – Nima.S-H Apr 16 '18 at 11:09
  • Oh yeah, missed your actual problem. 1.8.0 on ubuntu and cmake. Is it just about the visualizer? Might be related to this.. https://stackoverflow.com/questions/40603535/linker-error-lnk-2019-lnk1120-using-pcl-1-8-0-1-6-0 – Rooscannon Apr 16 '18 at 13:10
  • I downgrade pcl to 1.6.0 but I have this error ; Error C4996 'pcl::SHOT': USE SHOT352 FOR SHAPE AND SHOT1344 FOR SHAPE+COLOR INSTEAD SamplePCL e:\program files\pcl 1.6.0\include\pcl-1.6\pcl\impl\point_types.hpp 1009 – Nima.S-H Apr 17 '18 at 14:17