0

I would like to know if anyone knows how I can solve the error: libQt6OpenGL.so.6: cannot open shared object file: No such file or directory

On my CMakeLists.txt I have the following:

cmake_minimum_required(VERSION 3.22)
project(PRJ)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

set(CMAKE_PREFIX_PATH "/opt/Qt/6.3.0/gcc_64/lib/cmake")
find_package(Qt6 REQUIRED COMPONENTS Widgets OpenGLWidgets)

set(VTK_DIR "/usr/local/include/vtk-9.1/")
find_package(VTK REQUIRED)

find_package(PCL 1.12 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})

find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )

add_executable(PRJ ...)
target_link_libraries(PRJ PRIVATE ${VTK_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBS} Qt6::Core Qt6::Gui Qt6::Widgets Qt6::OpenGLWidgets)

I am using KUbuntu 22.04 with Qt6.3. PCL version 1.12, VTK 9.1 and OpenCV 4.5.5.

Alex Reinking
  • 16,724
  • 5
  • 52
  • 86
  • You need to tell the linker where to find the library `libQt6OpenGL.so.6`. [That question](https://stackoverflow.com/questions/480764/linux-error-while-loading-shared-libraries-cannot-open-shared-object-file-no-s) and its answers describe many ways for doing that. – Tsyvarev May 30 '22 at 21:47
  • I came across the same issue. It turns out it's `libvtkGUISupportQt-9.2.so`, rather than the project executable, cannot find Qt libraries since they're not in the ld search path (Your Qt is in `/opt/Qt/6.3.0`, which won't be searched by ld in default). Therefore, changing your own CMakeLists.txt (adding rpath or whatever) can hardly address this. You should just modify the LD_LIBRARY_PATH environment variable. Or set `CMAKE_INSTALL_RPATH_USE_LINK_PATH` to True when installing your custom built VTK. – tanjor Nov 24 '22 at 04:03

0 Answers0