PointCloudLibrary / pcl

Point Cloud Library (PCL)
https://pointclouds.org/
Other
9.86k stars 4.61k forks source link

PCLVisualizer tutorial issue on Windows #1601

Open SergioRAgostinho opened 8 years ago

SergioRAgostinho commented 8 years ago

There's been some people getting exceptions on the PCLVisualizer tutorial on Windows platforms. More info in threads http://www.pcl-users.org/Can-t-visualize-normals-Exception-thrown-td4041574.html http://www.pcl-users.org/Access-Violation-vtkOpenGLBufferObject-GenerateBuffer-enum-vtkOpenGLBufferObject-ObjectType-td4041634.html

@UnaNancyOwen do you mind giving it a try? You're kind of our Windows person :)

UnaNancyOwen commented 5 years ago

@larshg I have some questions.

larshg commented 5 years ago

@UnaNancyOwen Ah, I haven't compiled boost lately, so its still from a vs2015( toolset v140) build I think.

As per VTK I don't think so, though I build the shared libaries - instead of statics?

UnaNancyOwen commented 5 years ago

@larshg Could you try with VTK static libraries? Thanks,

UnaNancyOwen commented 5 years ago

As per VTK I don't think so, though I build the shared libaries - instead of statics?

I got an hints from report by @larshg. I tried this tutorial with VTK that built as dynamic link library. It works correctly with any runtime argument. 

command arguments VTK static link VTK dynamic link
-h operate correctly operate correctly
-s operate correctly operate correctly
-r operate correctly operate correctly
-c operate correctly operate correctly
-n runtime error operate correctly
-a runtime error operate correctly
-v runtime error operate correctly
-i operate correctly operate correctly

My test environment is as follows. They are all the latest versions.

Environment Version
MSVC 2019 (16.1.6)
Boost 1.70.0
Eigen 3.3.7
FLANN 1.9.1
QHull 2019.1
VTK 8.2.0

From the above results, I think that the cause of this issue is not the dependency version. That cause include in the linking way of VTK. We got some progress to resolve this issue. Thanks,

larshg commented 5 years ago

I can verify that static build VTK fails.

taketwo commented 5 years ago

OK, so at the very least we can switch to OpenGL2 when dynamic linking is used? This would be a big step forward already.

UnaNancyOwen commented 5 years ago

OK, so at the very least we can switch to OpenGL2 when dynamic linking is used?

Yes.

UnaNancyOwen commented 5 years ago

@taketwo @SergioRAgostinho I want to check again whether this issue only occurs on Windows. Could you try this tutorial using PCL linking VTK statically and dynamically on Linux, Mac.

larshg commented 5 years ago

I tried to create a minimal example rendering a sphere, cone, line and plane using VTK directly and it runs fine. So it seems to be a misuse/configuration in PCL.

larshg commented 5 years ago

I have rattled the box at VTK here. The above test, was not correct as the offending methods that I have found was not called.

See my comment at VTK for my latest findings.

SergioRAgostinho commented 5 years ago

Super, thank you for digging deep on this.

larshg commented 5 years ago

I have updated my comment at VTK, which closed the issue - I have asked for reopening it.

I got a simple sphere rendered in a unit test for the PCLVisualizer using only VTK calls.

But I can't get the PCLVisualizer to work.

If I add a line and a sphere, it successfully render the line, but fails when rendering the sphere.

If I switch the two unit test, so that the VTK only version is run first - the second one using PCLVisualizer works as well.

See them here

I'm getting a bit tiresome of this error!

Lars

larshg commented 5 years ago

I think we simply can't integrate static VTK into dynamic PCL dlls.

If I compile PCL static as well, all works as expected.

I did find a flag for g++ like this, which maybe could have solved the issue, but I haven't found a equivalent for MSVC - nor if it matters for MSVC.

It seems that some functions is not correctly found (NULL pointers) - depending on the code layout - but I'm almost guessing now as its way beyond my knowledge of compiler and linking.

Regards Lars

UnaNancyOwen commented 5 years ago

It will take time to fully resolve this issue. However, We may need to next release without waiting for this issue to be resolved. We would choose to release pre-built PCL with dynamic linked VTK as a temporary solution in that case. I propose adding (temporarily) a script that adds the VTK path (PCL_ROOT/3rdParty/VTK/bin) to the environment variable in install process of PCL All-in-one Installer.

What do you think?

taketwo commented 5 years ago

This sounds like the most reasonable approach. Do you know if there are any deficits or potential problems if we go this way?

UnaNancyOwen commented 5 years ago

I think there's nothing. It just add/remove the VTK path for temporary solution. I have already tested this installer/uninstaller on my environment. It works correctly without problem which option choose.

  C:\Program Files\PCL\bin
+ C:\Program Files\PCL\3rdParty\VTK\bin

Also, It means we are ready to generate and publish the PCL 1.10.0 All-In-One Installer (that include pre-built PCL with dynamic linked VTK as a temporary solution for this issue).

didory123 commented 5 years ago

I'm not sure if this is the right place to make further comments, but for anyone else working with PCL on Windows who had been searching for a solution to this issue:

I had to add the following lines

include

VTK_MODULE_INIT(vtkRenderingOpenGL);

to a cpp source file before including any other vtk libraries (meaning that these lines need to go before say, the PCL visualization module which itself includes the VTK libraries) as per explained in this vtk migration guide page. However, this means that you can't use precompiled headers to include the PCL modules that do use vtk, so you'll have to find some other workaround for that.

stale[bot] commented 4 years ago

Marking this as stale due to 30 days of inactivity. It will be closed in 7 days if no further activity occurs.

kunaltyagi commented 4 years ago

@UnaNancyOwen does this issue only occur with deprecated OpenGL bindings? If so, we can consider the "temporary" solution as a bit more permanent (and close this issue). If it occurs with OpenGL2 bindings too, then we need to continue looking for solutions.

UnaNancyOwen commented 4 years ago

@kunaltyagi It works fine with OpenGL1 rendering backend that deprecated/removed option in VTK, but it not works fine with OpenGL2 rendering backend that built as a static linking library. It has been worked around by linking VTK that built as a dynamic linking library as temporary workaround. (As a bad side effects, developers have to attached many many dependent dll files of VTK when they distribute their applications.)

kunaltyagi commented 4 years ago

it not works fine with OpenGL2 rendering backend

Oh. That's the reverse of expected situation. Got it 😄

kunaltyagi commented 4 years ago

Bumping off milestones due to lack of activity

AndreV84 commented 4 years ago

@UnaNancyOwen is there a recent PCL for windows release?

UnaNancyOwen commented 4 years ago

@AndreV84 The latest version of PCL All-in-one Installer has been published now! Please see release page.

Cras1990 commented 3 years ago

The latest version of PCL All-in-one Installer has been published now! Please see release page.

@UnaNancyOwen I tried with pcl-1.11.1 all in one installer and I´m still having issue:

image image

and many more such errors concering vtk dll files.

Has a solution for this kind of issues been already found? I cannot run visualizer in windows because of this. Or is my issue comming from something different? Thanks in advance.

UnaNancyOwen commented 3 years ago

@Cras1990 The pre-built PCL are use dynamically linked VTK. Therefore, You need to add %PCL_ROOT%\3rdParty\VTK\bin to environment variable PATH of your system. Please read the log of this issue. https://github.com/PointCloudLibrary/pcl/issues/1601#issuecomment-640987634