0

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?

Buzzy
  • 21
  • 1
  • 6
  • My advice is to use CMake to generate your Visual Studio project instead of handling this on your own. – drescherjm Nov 12 '14 at 15:02
  • I want to include the PCL in an existing project. That's why I added the dependencies manually. Do you also recommend CMake for existing projects because I am a bit scared that it will destroy the other dependencies... – Buzzy Nov 12 '14 at 15:14
  • It depends on how complex the preexisting project is. An alternate option is to create a simple test application using a CMake generated project that includes the dependencies that you need then in Visual Studio IDE copy the dependencies from the CMake project to your project. – drescherjm Nov 12 '14 at 16:10
  • That's a great idea. I will try it with the cmake data of the pcl tutorial. I will let you know about the effort! – Buzzy Nov 12 '14 at 16:28
  • A nice thing about this approach is that if you keep the CMake project in the future if you update vtk, pcl... You can just regenerate in CMake and copy the updated dependencies in the IDE. – drescherjm Nov 12 '14 at 16:31
  • I created a little project based on the [greedy_projection.cpp](http://pointclouds.org/documentation/tutorials/greedy_projection.php#greedy-triangulation) code. 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? – Buzzy Nov 13 '14 at 13:21
  • Sorry, I can't help with /CLR errors. I do not use CLR in any of my projects. – drescherjm Nov 13 '14 at 16:31

2 Answers2

0

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

Buzzy
  • 21
  • 1
  • 6
0

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_;
Wurth
  • 11
  • 3