2

I referred this link. And I have the same problem.

PCLVisualizer addPointCloud crashes

I am using Qt C++.

I am using PCL1.8 (C:\Program Files\PCL1.8.0) I am using Windows 7 OS. All lib dependencies are given for PCL and VTK The application is not compiling. There is a link Error. MSVC compiler 64 bit. Following is my code snippet.

    void MainWindow::on_pushButton_5_clicked()
{
 pcl::PointCloud::Ptr cloud (new pcl::PointCloud) ; 
 int size=45; 
 cloud->resize(45); 
 for(int ix=0;ix!=45;ix++) 
  { 
    cloud->points[ix].x=ix; 
    cloud->points[ix].y=ix; 
    cloud->points[ix].z=ix;      
    cloud->points[ix].intensity=1; 
  }
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));

     viewer->setBackgroundColor (0.5, 0.5, 0.5);
     viewer->addPointCloud<pcl::PointXYZI> (cloud, "sample cloud");
     viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "sample cloud");
     viewer->addCoordinateSystem (1.0);
     while (!viewer->wasStopped ())
     {
             viewer->spinOnce (100);
             boost::this_thread::sleep (boost::posix_time::microseconds   
            (100000));
     }
}

The error is attached below Link Error image

Community
  • 1
  • 1
Nidhin KR
  • 45
  • 9

1 Answers1

1

According to MSDN here and here you need to link User32.lib and Gdi32.lib

in .pro file:

LIBS += -lUser32 -lGdi32

Full solution might be found here.

Community
  • 1
  • 1
Max Go
  • 2,092
  • 1
  • 16
  • 26
  • Something happened. There were more than 10 link errors.It reduced to 1 error.vtkCommonCore-7.0-gd.lib(vtkWin32OutputWindow.obj):-1: error: LNK2019: unresolved external symbol __imp_GetStockObject referenced in function "protected: static int __cdecl vtkWin32OutputWindow::Initialize(void)" (?Initialize@vtkWin32OutputWindow@@KAHXZ) – Nidhin KR Feb 19 '17 at 08:50
  • Have updated the answer ... linking to Gdi32.lib is missed ... in future please search for missed function source module and just link it in similar way, it's not hard to find out, thanks – Max Go Feb 19 '17 at 10:20
  • Thank you Max. You are correct. Now the error gone. – Nidhin KR Feb 19 '17 at 15:25