Tag Archives: LNK2001 error

Solve error LNK2001 about pcl::io::vtkPolyDataToPointCloud

When use function ‘pcl::io::vtkPolyDataToPointCloud’ in PCL 1.6.0, one may have error as follows:

 

1>demo.obj : error LNK2001: unresolved external symbol "void __cdecl pcl::io::vtkPolyDataToPointCloud<struct pcl::PointXYZRGB>(class vtkPolyData * const,class pcl::PointCloud<struct pcl::PointXYZRGB> &)" (??$vtkPolyDataToPointCloud@UPointXYZRGB@pcl@@@io@pcl@@YAXQAVvtkPolyData@@AAV?$PointCloud@UPointXYZRGB@pcl@@@1@@Z)
1>G:\projects\demo\demo.exe : fatal error LNK1120: 1 unresolved externals

 

This happens because function ‘pcl::io::vtkPolyDataToPointCloud’ has not been integrated in ‘pcl_io_release.lib’ library, instead it is implemented in the file ‘vtk_lib_io.hpp’, so we need to include both the header file and the hpp file:

 

#include <pcl/io/vtk_io.h>
#include <pcl/io/vtk_lib_io.h>
#include <pcl/io/vtk_lib_io.hpp>