Unable to include dependent .so libraries when generating .deb package for Qt application
-
I’m building a Qt C++ application for Linux (Ubuntu), and I want to distribute it as a .deb package.
However, I’m unable to include the required .so dependency files (for example libQt6WebEngineCore.so, libQt6WebView.so, etc.) inside the generated .deb installer.When I install the .deb on another system (without Qt installed), the app fails to start due to missing shared libraries.
I wanted to know, How to add required dependency to .deb file ?Environment:
Qt Version: 6.10.0
OS: Ubuntu 22.04.5
Build Tool: CMake -
I’m building a Qt C++ application for Linux (Ubuntu), and I want to distribute it as a .deb package.
However, I’m unable to include the required .so dependency files (for example libQt6WebEngineCore.so, libQt6WebView.so, etc.) inside the generated .deb installer.When I install the .deb on another system (without Qt installed), the app fails to start due to missing shared libraries.
I wanted to know, How to add required dependency to .deb file ?Environment:
Qt Version: 6.10.0
OS: Ubuntu 22.04.5
Build Tool: CMake@smit.patel said in Unable to include dependent .so libraries when generating .deb package for Qt application:
due to missing shared libraries
Which libraries exactly are missing? Were those libs installed by your deb package and if so where exactly?
-
Hi and welcome to devnet,
Why not declare that your package depends on Qt 6 ?
That will trigger proper installation of Qt on the target system. -
cmake_minimum_required(VERSION 4.0) project(desk_pos_test) set(CMAKE_CXX_STANDARD 20) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) # Tell the binary to look for libraries inside ../lib relative to executable set(CMAKE_BUILD_RPATH "$ORIGIN/../lib") set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib") find_package(Qt6 COMPONENTS Core Gui Widgets WebEngineWidgets WebEngineCore REQUIRED) qt6_wrap_cpp(MOC_SOURCES main.cpp) add_executable(desk_pos_test main.cpp main.cpp ) target_link_libraries(desk_pos_test Qt::Core Qt::Gui Qt::Widgets Qt::WebEngineWidgets Qt::WebEngineCore ) install(TARGETS desk_pos_test RUNTIME DESTINATION bin ) ## ✅ Install Qt libraries (if you ship them) #install(DIRECTORY ${CMAKE_SOURCE_DIR}/packages/com.medkart.desktopPos/data/lib/ # DESTINATION lib/desk-pos-app #) function(copy_qt_lib libname) get_target_property(_qt_lib_location Qt6::${libname} LOCATION) install(FILES ${_qt_lib_location} DESTINATION lib/desk-pos-app ) endfunction() # Copy only the required modules copy_qt_lib(Core) copy_qt_lib(Gui) copy_qt_lib(Widgets) copy_qt_lib(WebEngineCore) copy_qt_lib(WebEngineWidgets) copy_qt_lib(WebChannel) # ✅ Install resources to /usr/local/share/desk-pos-app install(DIRECTORY ${CMAKE_SOURCE_DIR}/packages/com.medkart.desktopPos/data/ DESTINATION share/desk-pos-app FILES_MATCHING PATTERN "*" EXCLUDE PATTERN "lib/*" ) install(FILES ${CMAKE_SOURCE_DIR}/resources/desk-pos-app.desktop DESTINATION /usr/share/applications) install(FILES ${CMAKE_SOURCE_DIR}/resources/desk-pos-app.svg DESTINATION /usr/share/pixmaps)I am packaging my Qt6 application as a .deb using the CMake setup shown above, which installs the executable, resources, and Qt libraries. and run the following command to make the .deb file, from project folder in terminal
rm -rf build mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release cpack -G DEBIs this an appropriate method for distributing a Qt application to other Linux systems?
How can I optimize this CMake configuration for more reliable deployment and easier updates?