Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pcl libraries and vtk cannot be compiled together with cmakelists #6212

Open
weiOverlord opened this issue Jan 6, 2025 · 11 comments
Open

pcl libraries and vtk cannot be compiled together with cmakelists #6212

weiOverlord opened this issue Jan 6, 2025 · 11 comments

Comments

@weiOverlord
Copy link

Describe the error

PCL_Version :1.14
VTK_version:8.2
ubuntu:22.04

CMakelists:
set(VTK_DIR "/usr/local/inclue/vtk-8.2")
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(PCL REQUIRED)
find_package(VTK REQUIRED NO_MODULE)
find_package(Boost REQUIRED)
find_package(Eigen REQUIRED)
find_package(pcl_conversions REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2_sensor_msgs REQUIRED)
find_package(pcl_ros REQUIRED)
find_package(visualization_msgs REQUIRED)
find_package(nav_msgs REQUIRED)

Error:
CMake Error at /usr/local/lib/cmake/vtk-8.2/vtkModuleAPI.cmake:140 (message):
Requested modules not available:

ChartsCore
CommonColor
CommonComputationalGeometry
CommonCore
CommonDataModel
CommonExecutionModel
CommonMath
CommonMisc
CommonTransforms
FiltersCore
FiltersExtraction
FiltersGeneral
FiltersGeometry
FiltersModeling
FiltersSources
ImagingCore
ImagingSources
InteractionImage
InteractionStyle
InteractionWidgets
IOCore
IOGeometry
IOImage
IOLegacy
IOPLY
RenderingAnnotation
RenderingCore
RenderingContext2D
RenderingLOD
RenderingFreeType
ViewsCore
ViewsContext2D
RenderingOpenGL2
GUISupportQt

Call Stack (most recent call first):
/usr/local/lib/cmake/vtk-8.2/VTKConfig.cmake:143 (vtk_module_config)
/usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:270 (find_package)
/usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:319 (find_VTK)
/usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:540 (find_external_library)
CMakeLists.txt:15 (find_package)

If the vtk version is not specified in the first set, the compilation is OK, but the VTK version is identified as 9.1, and an exception will occur when executing the following code.

    viewer = new pcl::visualization::PCLVisualizer("window");
    viewer->setBackgroundColor(0, 0, 0);
    viewer->addPointCloud<pcl::PointXYZ>(cloud, "cloud1");
    viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 2, "cloud1");
    viewer->addCoordinateSystem(1.0);
    viewer->initCameraParameters();
    //viewer->spinOnce();
    viewer->removeAllPointClouds();
    viewer->removeAllShapes();

while (!viewer->wasStopped ())
  {
    viewer->spinOnce (100);
    boost::this_thread::sleep (boost::posix_time::microseconds (100000));
  }

If this statement (viewer->wasStopped ()) is executed, the program immediately reports an error,Is this some kind of conflict?

@weiOverlord weiOverlord added kind: compile error Type of issue status: triage Labels incomplete labels Jan 6, 2025
@mvieth
Copy link
Member

mvieth commented Jan 6, 2025

@weiOverlord Does that mean you have multiple VTK installations on your computer? VTK 8.2 and VTK 9.1? Unless there is a strong reason why you need both, I would recommend keeping only one of them and removing the other. Getting all programs to use the correct one is usually a major headache. Since you compiled PCL from source anyway (I assume), doing so again in case you decide to remove VTK 9.1 should not be a problem.

If this statement (viewer->wasStopped ()) is executed, the program immediately reports an error

I can't tell you anything about that unless you provide further information, for example the error message, or better: a stack trace from gdb or valgrind.

@mvieth mvieth added module: visualization and removed status: triage Labels incomplete labels Jan 6, 2025
@weiOverlord
Copy link
Author

vtk9.1 came with me after installing ros-humble desktop. I did not install the source code. It was automatically generated in usr/lib/x86_64-linux-gnu/cmake/vtk9.1 after installing ros2。
For this function problem, I did not do any other display, just want to start the keyboard and mouse event, where I executed viewer->spinOnce(1000) statement alone, the program will wait for 1s to crash, the same way viewer->spinOnce(10000), wait for 10s of the program crash, If you change it to viewer->spin(), the program does not crash, but it is blocked and cannot register keyboard and mouse events.

@mvieth
Copy link
Member

mvieth commented Jan 7, 2025

vtk9.1 came with me after installing ros-humble desktop. I did not install the source code. It was automatically generated in usr/lib/x86_64-linux-gnu/cmake/vtk9.1 after installing ros2。

It was probably installed via apt. Have you considered removing it (sudo apt remove libvtk9-dev)? Or would that remove other apt packages that you want to keep? Alternatively, have you considered removing VTK 8.2? Why did you even install VTK 8.2 when you already had VTK 9.1?

For this function problem, I did not do any other display, just want to start the keyboard and mouse event, where I executed viewer->spinOnce(1000) statement alone, the program will wait for 1s to crash, the same way viewer->spinOnce(10000), wait for 10s of the program crash, If you change it to viewer->spin(), the program does not crash, but it is blocked and cannot register keyboard and mouse events.

Do you mean listening for keyboard/mouse events with registerKeyboardCallback/registerMouseCallback? You can find an example for that here: https://pcl.readthedocs.io/projects/tutorials/en/master/pcl_visualizer.html
And again: if there is a crash, please run your program with gdb or valgrind, and post the stack trace of the crash. Otherwise I cannot help you find the reason for the crash.

@weiOverlord
Copy link
Author

I tried to delete vtk9.1 before, and then deleted the play, resulting in other dependencies appear abnormal, some component packages will automatically rely on vtk9.1, I here vtk9.1 is not installed by apt, but after installing ros2-humble desktop automatically in the system directory. Then I want to change to vtk8.2 library for compilation, the results of the compilation error, I show the top. If no vtk path is specified above, no error is reported when compiling. Tomorrow I will try gdb to query this abnormal crash problem. Thank you very much for your answer. Thank you

@weiOverlord
Copy link
Author

I tried gdb capture and found the following questions:
2025-01-08 09:14:04.177 ( 0.426s) [ E278C580]vtkOpenGLPolyDataMapper:306 WARN| vtkOpenGLPolyDataMapper::GetVertexShaderCode was deprecated for VTK 9.0 and will be removed in a future version. Use vtkOpenGLShaderProperty::GetVertexShaderCode instead.
2025-01-08 09:14:04.177 ( 0.426s) [ E278C580]vtkOpenGLPolyDataMapper:298 WARN| vtkOpenGLPolyDataMapper::SetVertexShaderCode was deprecated for VTK 9.0 and will be removed in a future version. Use vtkOpenGLShaderProperty::SetVertexShaderCode instead.
2025-01-08 09:14:04.177 ( 0.426s) [ E278C580]vtkOpenGLPolyDataMapper:336 WARN| vtkOpenGLPolyDataMapper::GetGeometryShaderCode was deprecated for VTK 9.0 and will be removed in a future version. Use vtkOpenGLShaderProperty::GetGeometryShaderCode instead.
2025-01-08 09:14:04.177 ( 0.426s) [ E278C580]vtkOpenGLPolyDataMapper:328 WARN| vtkOpenGLPolyDataMapper::SetGeometryShaderCode was deprecated for VTK 9.0 and will be removed in a future version. Use vtkOpenGLShaderProperty::SetGeometryShaderCode instead.
2025-01-08 09:14:04.177 ( 0.426s) [ E278C580]vtkOpenGLPolyDataMapper:321 WARN| vtkOpenGLPolyDataMapper::GetFragmentShaderCode was deprecated for VTK 9.0 and will be removed in a future version. Use vtkOpenGLShaderProperty::GetFragmentShaderCode instead.
2025-01-08 09:14:04.177 ( 0.426s) [ E278C580]vtkOpenGLPolyDataMapper:313 WARN| vtkOpenGLPolyDataMapper::SetFragmentShaderCode was deprecated for VTK 9.0 and will be removed in a future version. Use vtkOpenGLShaderProperty::SetFragmentShaderCode instead.
2025-01-08 09:14:04.177 ( 0.426s) [ E278C580]vtkOpenGLPolyDataMapper:306 WARN| vtkOpenGLPolyDataMapper::GetVertexShaderCode was deprecated for VTK 9.0 and will be removed in a future version. Use vtkOpenGLShaderProperty::GetVertexShaderCode instead.
2025-01-08 09:14:04.177 ( 0.426s) [ E278C580]vtkOpenGLPolyDataMapper:298 WARN| vtkOpenGLPolyDataMapper::SetVertexShaderCode was deprecated for VTK 9.0 and will be removed in a future version. Use vtkOpenGLShaderProperty::SetVertexShaderCode instead.
2025-01-08 09:14:04.177 ( 0.426s) [ E278C580]vtkOpenGLPolyDataMapper:336 WARN| vtkOpenGLPolyDataMapper::GetGeometryShaderCode was deprecated for VTK 9.0 and will be removed in a future version. Use vtkOpenGLShaderProperty::GetGeometryShaderCode instead.
2025-01-08 09:14:04.177 ( 0.426s) [ E278C580]vtkOpenGLPolyDataMapper:328 WARN| vtkOpenGLPolyDataMapper::SetGeometryShaderCode was deprecated for VTK 9.0 and will be removed in a future version. Use vtkOpenGLShaderProperty::SetGeometryShaderCode instead.
2025-01-08 09:14:04.177 ( 0.426s) [ E278C580]vtkOpenGLPolyDataMapper:321 WARN| vtkOpenGLPolyDataMapper::GetFragmentShaderCode was deprecated for VTK 9.0 and will be removed in a future version. Use vtkOpenGLShaderProperty::GetFragmentShaderCode instead.
2025-01-08 09:14:04.177 ( 0.426s) [ E278C580]vtkOpenGLPolyDataMapper:313 WARN| vtkOpenGLPolyDataMapper::SetFragmentShaderCode was deprecated for VTK 9.0 and will be removed in a future version. Use vtkOpenGLShaderProperty::SetFragmentShaderCode instead.
[Thread 0x7fff7aa00640 (LWP 14182) exited]
[Thread 0x7fff7b400640 (LWP 14181) exited]
[Thread 0x7fff7be00640 (LWP 14180) exited]
[Thread 0x7fff84c00640 (LWP 14179) exited]
[Thread 0x7fff85600640 (LWP 14178) exited]
[Thread 0x7fff86000640 (LWP 14177) exited]
[Thread 0x7fff86a00640 (LWP 14176) exited]
[Thread 0x7fff87400640 (LWP 14175) exited]
[Thread 0x7fff87e00640 (LWP 14174) exited]
[Thread 0x7fff90c00640 (LWP 14173) exited]
[Thread 0x7fff91600640 (LWP 14172) exited]
[Thread 0x7fff92000640 (LWP 14171) exited]
[Thread 0x7fff92a00640 (LWP 14170) exited]
[Thread 0x7fff93400640 (LWP 14169) exited]
[Thread 0x7fff93e00640 (LWP 14168) exited]
[Thread 0x7fff9ce00640 (LWP 14167) exited]

Thread 1 "obs_monitor_cpp" received signal SIGSEGV, Segmentation fault.
0x00007fffe9646c10 in _XEventsQueued () from /lib/x86_64-linux-gnu/libX11.so.6

Can I ask cmakelists to specify to look for vtk8.2 compilation now? I think there seems to be some conflict between vkt9.1 and pcl1.14.

@mvieth
Copy link
Member

mvieth commented Jan 8, 2025

I tried to delete vtk9.1 before, and then deleted the play,

"deleted the play"? What do you mean?

resulting in other dependencies appear abnormal, some component packages will automatically rely on vtk9.1, I here vtk9.1 is not installed by apt, but after installing ros2-humble desktop automatically in the system directory.

But I assume ros2-humble was installed via apt? Then vtk9.1 was probably installed automatically by apt because it is the dependency of some ros2 package.

Then I want to change to vtk8.2 library for compilation

But why do you want to change to vtk8.2?

If no vtk path is specified above, no error is reported when compiling

You compiled PCL from source yourself, is that correct? Which PCL version exactly, PCL 1.14.0 or PCL 1.14.1, or the current PCL master branch?
And just to be sure: Do you only have PCL 1.14 installed? Or could there be other versions of PCL installed on your computer? For example, installed automatically by apt when you installed ros2?

When PCL was compiled, it used VTK 9.1. Therefore, in find_package(PCL REQUIRED), it tries to find VTK 9.1 again. If you force it to find VTK 8.2 by setting the VTK_DIR, that compilation error you showed above happens.

vtkOpenGLPolyDataMapper::GetVertexShaderCode was deprecated for VTK 9.0 and will be removed in a future version. Use vtkOpenGLShaderProperty::GetVertexShaderCode instead.

These warnings are caused by VTK code. You can ignore them, they do not cause any problem. These warnings disappear in a newer VTK version. See: https://discourse.vtk.org/t/vtk-9-0-rc1/2916

Thread 1 "obs_monitor_cpp" received signal SIGSEGV, Segmentation fault.
0x00007fffe9646c10 in _XEventsQueued () from /lib/x86_64-linux-gnu/libX11.so.6

Where is the stack trace (backtrace)? Please post it.

I think there seems to be some conflict between vkt9.1 and pcl1.14.

That is unlikely because these two versions have been tested repeatedly together, without problems. In fact, I just tested the code you posted at the top with VTK 9.1 and PCL 1.14 (the current master branch, to be precise). It worked without any problem.

@weiOverlord
Copy link
Author

I uninstalled the pcl1.14.0 version of the library and re-source the pcl1.12.0 version. Then recompile the project, such as the following file:
test.md

I really can't find out where the conflict, but also hope more advice

@mvieth
Copy link
Member

mvieth commented Jan 8, 2025

I uninstalled the pcl1.14.0 version of the library and re-source the pcl1.12.0 version. Then recompile the project, such as the following file: test.md

What? Why? Did you read my last comment? I am pretty sure that there is no conflict between PCL 1.14 and VTK 9.1. And I am trying to help you find a solution to your problem, but if you do not answer my questions and do something completely different from what I have recommended, then I really cannot help you.

@weiOverlord
Copy link
Author

For the previous answer, I'm sorry, I will change back to pcl1.14 version tomorrow. What I wanted to express before is that the version that comes with the download through ros-humble desktop does not have the complete information of the entire library after the compilation of vtk9.1 source code, so I will not use vtk9.1 in the later project. Because some of the.so files I wanted to download through ros-humble desktop did not have vtk9.1, so I would like to use the vtk-8.2 version, and the built-in vtk9.1 version cannot be deleted. Once deleted, other related library links will appear abnormal. Sorry again. Glad to hear from you.

@mvieth
Copy link
Member

mvieth commented Jan 8, 2025

It is difficult to understand what you mean in your last comment:

What I wanted to express before is that the version that comes with the download through ros-humble desktop does not have the complete information of the entire library ...

VTK 9.1 does not have complete information? What is missing? C++ functions? C++ classes? Files? If yes, which ones?

... after the compilation of vtk9.1 source code, ...

I am confused. Did you compile VTK 9.1 from source? Meaning, did you download the VTK 9.1 source code, then build it with cmake and make?

... so I will not use vtk9.1 in the later project. Because some of the.so files I wanted to download through ros-humble desktop did not have vtk9.1, ...

Do you mean there are .so files of VTK 9.1 missing? If yes, which ones?

... so I would like to use the vtk-8.2 version, and the built-in vtk9.1 version cannot be deleted. Once deleted, other related library links will appear abnormal.

Which other libraries?

Please run the following commands and post the console output here:

  1. apt list libpcl-dev
  2. apt list libvtk9-dev
  3. find /usr -iname "vtk*config.cmake"
  4. find /usr -iname "pcl*config.cmake"

@weiOverlord
Copy link
Author

I had this error in the next installation of pcl1.14, the system had compiled pcl1.14.0. However, when the sudo make install command is executed, the following error occurs:

CMake Error at /usr/share/cmake-3.22/Modules/FindMPI.cmake:1264 (try_compile):
Failed to configure test project build system.
Call Stack (most recent call first):
/usr/share/cmake-3.22/Modules/FindMPI.cmake:1315 (_MPI_try_staged_settings)
/usr/share/cmake-3.22/Modules/FindMPI.cmake:1638 (_MPI_check_lang_works)
/usr/share/cmake-3.22/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
/usr/lib/x86_64-linux-gnu/cmake/boost_mpi-1.74.0/boost_mpi-config.cmake:117 (find_dependency)
/usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake:141 (find_package)
/usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake:258 (boost_find_component)
cmake/pcl_find_boost.cmake:27 (find_package)
CMakeLists.txt:423 (include

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants