简体   繁体   中英

error LNK2001 when including “pcl_visualizer.h”

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?

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!!

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_;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM