microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.28k stars 6.42k forks source link

Qt6.5.0 : Incorrect RUNPATH Configuration for libqxcb #40469

Open ershat-dl opened 3 months ago

ershat-dl commented 3 months ago

Description: I encountered an issue after using vcpkg to install and package a Qt6.5.0 project. The application fails to locate certain dynamic libraries on a new machine, despite these libraries being present in the lib folder under the application directory.

Steps to Reproduce: Use vcpkg to install Qt6.5.0 on a Linux system. Build and package a Qt application that includes the libqxcb plugin. Deploy the application on a different machine. Attempt to run the application.

Observed Behavior: The application fails with an error indicating that libqxcb cannot locate certain libraries, even though they exist in the lib directory of the application. Running readelf -d libqxcb reveals that the RUNPATH is set to $ORIGIN:$ORIGIN/../../../lib, which incorrectly points to the parent directory of the application folder instead of the correct lib directory within the application.

Root Cause: It appears that the issue is caused by the directory structure created by vcpkg when installing Qt. The structure includes an additional Qt6 folder, which affects the relative path calculation during RUNPATH configuration, resulting in an extra ../ in the RUNPATH.

Expected Behavior: The RUNPATH should correctly point to $ORIGIN:$ORIGIN/../../lib to ensure that the libraries in the lib directory are correctly found at runtime.

Proposed Solution: should remove Qt6 folder ??

Environment: OS: Ubuntu 20.04 vcpkg version: 2024-07-10-d2dfc73769081bdd9b782d08d27794780b7a99b9 Qt version: 6.5.0

Additional Context: This issue may impact other Qt-related plugins as well. Adjusting the RUNPATH manually is possible, but this should ideally be handled automatically by vcpkg during the installation or packaging process.

This issue is not limited to libqxcb but affects almost all dynamic libraries within the plugins folder. Manually modifying the RUNPATH for each library is not feasible. This should ideally be handled automatically by vcpkg during the installation or packaging process.

jimwang118 commented 3 months ago

Can you provide a minimal reproducible example?

jimwang118 commented 3 months ago

I wrote a test program locally, and when I checked the RUNPATH, it showed the library path installed by vcpkg. image

ershat-dl commented 3 months ago

image

here is vcpkg.json:

{
  "name": "robot-x",
  "version": "1.0.0",
  "dependencies": [
    "qtbase",  "qttools", "qtcharts", "qtquickcontrols2", "qtsvg", "qtdoc",
    "onnxruntime",
    {
        "name": "qtmultimedia",
        "features": ["gstreamer"]
    },
    {
        "name": "harfbuzz",
        "features": ["glib"]
    }
  ],
  "overrides": [
    { "name": "qtbase", "version": "6.5.0" },
    { "name": "qttools", "version": "6.5.0" },
    { "name": "litehtml", "version": "0.6.0" },
    { "name": "qtmultimedia", "version": "6.5.0" },
    { "name": "qtcharts", "version": "6.5.0" },
    { "name": "qtdeclarative", "version": "6.5.0" },
    { "name": "qtdeclarative", "version": "6.5.0" },
    { "name": "qtsvg", "version": "6.5.0" },
    { "name": "qtdoc", "version": "6.5.0" }

  ],
  "builtin-baseline": "576379156e82da642f8d1834220876759f13534d"
}
github-actions[bot] commented 2 months ago

This is an automated message. Per our repo policy, stale issues get closed if there has been no activity in the past 28 days. The issue will be automatically closed in 14 days. If you wish to keep this issue open, please add a new comment.