error LNK2001 when including “pcl_visualizer.h”

久未见 提交于 2019-12-10 11:54:03

问题


I want to visualize a point cloud using the point-cloud-library. I already included:

#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/kdtree/kdtree_flann.h>
#include <pcl/features/normal_3d.h>
#include <pcl/surface/gp3.h>

without any problem, but when I add

#include <pcl/visualization/pcl_visualizer.h>

to my code I receive an LNK2001 error.

Fehler 51 error LNK2001: Nicht aufgelöstes externes Symbol ""public: virtual void __cdecl pcl::visualization::PCLVisualizer::FPSCallback::Execute(class vtkObject *,unsigned long,void *)" (?Execute@FPSCallback@PCLVisualizer@visualization@pcl@@UEAAXPEAVvtkObject@@KPEAX@Z)"

I think there is a library missing but I can't figure out which one. This is the list with the additional dependencies of my program:

  • pcl_common_debug.lib
  • pcl_io_debug.lib
  • pcl_kdtree_debug.lib
  • pcl_features_debug.lib
  • pcl_surface_debug.lib
  • pcl_search_debug.lib
  • pcl_visualization_debug.lib
  • vtkCommonCore-6.1.lib
  • vtksys-6.1.lib
  • and some opencv libs

can anyone tell me which library is missing?

Thanks in advance!

edit:

I created a little cpp-file based on the greedy_projection.cpp code. Thanks to the advice of drescherjm, I used cmake to create the project and I could compile it without errors. Then I wanted to include the stuff in my other project but the same error occurred. Now I figured out, that the reason for the error is the \clr flag. I have a Windows.Forms Project so it is compiled with \clr. The greedy_projection.cpp Project was compiled without this flag. Is there any way to avoid this incompatibility of pcl_visualizer.h with \clr?


回答1:


I could solve the issue!

I just commented the code inside of the

struct FPSCallback : public vtkCommand

function of pcl/visualization/pcl_visualizer.h. Then everything compiled fine. I dont need the FPSCallback so it's a perfect solution for me to run my code with \clr support.

Thanks drescherjm for your help!!




回答2:


I solved this issue by placing the pcl_visualizer code into my managed c++ code at the top. I had to add a header as well:

#include <vtkTextActor.h>

void
pcl::visualization::PCLVisualizer::FPSCallback::Execute(vtkObject* caller, unsigned long, void*)
{
    vtkRenderer *ren = reinterpret_cast<vtkRenderer *> (caller);
    float fps = 1.0f / static_cast<float> (ren->GetLastRenderTimeInSeconds());
    char buf[128];
    sprintf(buf, "%.1f FPS", fps);
    actor->SetInput(buf);
}

The other option is to go into pcl_visualizer.h and comment out the offending line (I do not know why this line causes issues, but I narrowed it down to this, and my vtk visualizer still works!):

  //FPSCallback (const FPSCallback& src) : vtkCommand (), actor (src.actor), pcl_visualizer (src.pcl_visualizer), decimated (src.decimated) {}

The code then looks like:

struct FPSCallback : public vtkCommand
{
  static FPSCallback *New () { return (new FPSCallback); }

  FPSCallback () : actor (), pcl_visualizer (), decimated () {}
  //FPSCallback (const FPSCallback& src) : vtkCommand (), actor (src.actor), pcl_visualizer (src.pcl_visualizer), decimated (src.decimated) {}
  FPSCallback& operator = (const FPSCallback& src) { actor = src.actor; pcl_visualizer = src.pcl_visualizer; decimated = src.decimated; return (*this); }

  virtual void 
  Execute (vtkObject*, unsigned long event_id, void*);

  vtkTextActor *actor;
  PCLVisualizer* pcl_visualizer;
  bool decimated;
};

/** \brief The FPSCallback object for the current visualizer. */
vtkSmartPointer<FPSCallback> update_fps_;


来源:https://stackoverflow.com/questions/26889614/error-lnk2001-when-including-pcl-visualizer-h

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!