简体   繁体   English

当包含“ pcl_visualizer.h”时,错误LNK2001

[英]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. 到我的代码,我收到LNK2001错误。

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)" Fehler 51错误LNK2001:Nichtaufgelöstesexternes符号“” public:虚拟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_common_debug.lib
  • pcl_io_debug.lib pcl_io_debug.lib
  • pcl_kdtree_debug.lib pcl_kdtree_debug.lib
  • pcl_features_debug.lib pcl_features_debug.lib
  • pcl_surface_debug.lib pcl_surface_debug.lib
  • pcl_search_debug.lib pcl_search_debug.lib
  • pcl_visualization_debug.lib pcl_visualization_debug.lib
  • vtkCommonCore-6.1.lib vtkCommonCore-6.1.lib
  • vtksys-6.1.lib vtksys-6.1.lib
  • and some opencv libs 和一些opencv库

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. 我根据greedy_projection.cpp代码创建了一个小cpp文件。 Thanks to the advice of drescherjm, I used cmake to create the project and I could compile it without errors. 感谢drescherjm的建议,我使用cmake创建了项目,并且可以毫无错误地对其进行编译。 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. 现在我弄清楚了,错误的原因是\\ clr标志。 I have a Windows.Forms Project so it is compiled with \\clr. 我有一个Windows.Forms项目,因此它是用\\ clr编译的。 The greedy_projection.cpp Project was compiled without this flag. greedy_projection.cpp项目的编译没有此标志。 Is there any way to avoid this incompatibility of pcl_visualizer.h with \\clr? 有什么方法可以避免pcl_visualizer.h与\\ 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. 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. 我不需要FPSCallback,因此它是使用\\ clr支持运行代码的理想解决方案。

Thanks drescherjm for your help!! 感谢drescherjm的帮助!

I solved this issue by placing the pcl_visualizer code into my managed c++ code at the top. 我通过将pcl_visualizer代码放在顶部的托管c ++代码中解决了此问题。 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!): 另一个选择是进入pcl_visualizer.h并注释掉有问题的行(我不知道为什么该行会引起问题,但我将其范围缩小了,而我的vtk visualizer仍然有效!):

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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