gpt4 book ai didi

c++ - Qt 应用程序中与 Qt 版本相关的运行时错误

转载 作者:太空狗 更新时间:2023-10-29 12:23:11 25 4
gpt4 key购买 nike

我正在使用 Qt Creator 在 Linux KDE neon 上开发和运行应用程序。

我的应用程序突然拒绝打开某些 URL,这个功能以前可以正常工作。我没有做任何更改,所以我猜某些 KDE neon 更新破坏了它。

当调用该函数时,我得到了这个调试输出:

kde-open5: /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5: version `Qt_5.11' not found (required by /usr/lib/x86_64-linux-gnu/libKF5KIOWidgets.so.5)
kde-open5: /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5: version `Qt_5.11' not found (required by /usr/lib/x86_64-linux-gnu/libKF5KIOCore.so.5)
kde-open5: /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5: version `Qt_5.11' not found (required by /usr/lib/x86_64-linux-gnu/libKF5I18n.so.5)
kde-open5: /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5: version `Qt_5.11' not found (required by /usr/lib/x86_64-linux-gnu/libKF5CoreAddons.so.5)
kde-open5: /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5: version `Qt_5.11' not found (required by /usr/lib/x86_64-linux-gnu/libKF5JobWidgets.so.5)
kde-open5: /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5: version `Qt_5.11' not found (required by /usr/lib/x86_64-linux-gnu/libKF5Service.so.5)
kde-open5: /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5: version `Qt_5.11' not found (required by /usr/lib/x86_64-linux-gnu/libKF5Completion.so.5)
kde-open5: /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5: version `Qt_5.11' not found (required by /usr/lib/x86_64-linux-gnu/libKF5IconThemes.so.5)
kde-open5: /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5: version `Qt_5.11' not found (required by /usr/lib/x86_64-linux-gnu/libKF5WindowSystem.so.5)
kde-open5: /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5: version `Qt_5.11' not found (required by /usr/lib/x86_64-linux-gnu/libKF5ConfigWidgets.so.5)
kde-open5: /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5: version `Qt_5.11' not found (required by /usr/lib/x86_64-linux-gnu/libKF5WidgetsAddons.so.5)
kde-open5: /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5: version `Qt_5.11' not found (required by /usr/lib/x86_64-linux-gnu/libKF5ConfigGui.so.5)
kde-open5: /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5: version `Qt_5.11' not found (required by /usr/lib/x86_64-linux-gnu/libKF5ConfigCore.so.5)
kde-open5: /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5: version `Qt_5.11' not found (required by /usr/lib/x86_64-linux-gnu/libKF5DBusAddons.so.5)
kde-open5: /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5: version `Qt_5.11' not found (required by /usr/lib/x86_64-linux-gnu/libKF5Auth.so.5)
kde-open5: /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5: version `Qt_5.11' not found (required by /usr/lib/x86_64-linux-gnu/libKF5Archive.so.5)
kde-open5: /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5: version `Qt_5.11' not found (required by /usr/lib/x86_64-linux-gnu/libKF5ItemViews.so.5)
kde-open5: /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5: version `Qt_5.11' not found (required by /usr/lib/x86_64-linux-gnu/libKF5Codecs.so.5)
kde-open5: /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5: version `Qt_5.11' not found (required by /usr/lib/x86_64-linux-gnu/libKF5GuiAddons.so.5)

据我所知,上面提到的两个路径是并发的,因为一个是由发行版创建的,一个是由 Qt Creator 创建的。

解决方案应该是在链接应用程序时使用 -rpath。我的应用程序是使用以下命令行构建的:

gcc -Wl,-rpath,/home/<user>/Qt/5.10.0/gcc_64/lib .....

我觉得不错。还将以下内容传递给 gcc:

-L/home/<user>/Qt/5.10.0/gcc_64/lib

这里缺少什么?为什么我的应用程序依赖于 Qt 5.11 库,而构建过程设置了正确的 Qt 5.10 路径?

更新,这就是 ldd 对我的可执行文件的评价。

linux-vdso.so.1 =>  (0x00007ffd08b1e000)
libQt5Widgets.so.5 => /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Widgets.so.5 (0x00007faa1849b000)
libQt5Gui.so.5 => /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Gui.so.5 (0x00007faa17cb3000)
libQt5DBus.so.5 => /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5DBus.so.5 (0x00007faa17a23000)
libQt5Xml.so.5 => /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Xml.so.5 (0x00007faa177e3000)
libQt5Script.so.5 => /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Script.so.5 (0x00007faa1735b000)
libQt5XmlPatterns.so.5 => /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5XmlPatterns.so.5 (0x00007faa16d83000)
libQt5Network.so.5 => /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Network.so.5 (0x00007faa169eb000)
libQt5Core.so.5 => /home/<user>/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5 (0x00007faa1629b000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007faa1607b000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007faa15cf3000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007faa159e3000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007faa157cb000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007faa153fb000)
/lib64/ld-linux-x86-64.so.2 (0x00007faa18cdb000)
libGL.so.1 => /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 (0x00007faa15183000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007faa14f63000)
libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007faa14d13000)
libicui18n.so.56 => /home/<user>/Qt/5.10.0/gcc_64/lib/libicui18n.so.56 (0x00007faa14873000)
libicuuc.so.56 => /home/<user>/Qt/5.10.0/gcc_64/lib/libicuuc.so.56 (0x00007faa144bb000)
libicudata.so.56 => /home/<user>/Qt/5.10.0/gcc_64/lib/libicudata.so.56 (0x00007faa12ad3000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007faa128cb000)
libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007faa126c3000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007faa123ab000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007faa1217b000)
libxcb-dri3.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-dri3.so.0 (0x00007faa11f73000)
libxcb-present.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-present.so.0 (0x00007faa11d6b000)
libxcb-sync.so.1 => /usr/lib/x86_64-linux-gnu/libxcb-sync.so.1 (0x00007faa11b63000)
libxshmfence.so.1 => /usr/lib/x86_64-linux-gnu/libxshmfence.so.1 (0x00007faa1195b000)
libglapi.so.0 => /usr/lib/x86_64-linux-gnu/libglapi.so.0 (0x00007faa1172b000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007faa11513000)
libXdamage.so.1 => /usr/lib/x86_64-linux-gnu/libXdamage.so.1 (0x00007faa1130b000)
libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007faa11103000)
libX11-xcb.so.1 => /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1 (0x00007faa10efb000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007faa10bbb000)
libxcb-glx.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0 (0x00007faa1099b000)
libxcb-dri2.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-dri2.so.0 (0x00007faa10793000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007faa1056b000)
libXxf86vm.so.1 => /usr/lib/x86_64-linux-gnu/libXxf86vm.so.1 (0x00007faa10363000)
libdrm.so.2 => /usr/lib/x86_64-linux-gnu/libdrm.so.2 (0x00007faa1014b000)
libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0 (0x00007faa18e43000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007faa0fedb000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007faa0fcd3000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007faa0facb000)
libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007faa0f8a3000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007faa0f69b000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007faa0f473000)
libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007faa0f18b000)
libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007faa0ef73000)

UPDATE2,/sbin/ldconfig -v 2>/dev/null | grep -v ^$'\t' 结果:

/usr/lib/x86_64-linux-gnu/libfakeroot:
/lib/i386-linux-gnu:
/usr/lib/i386-linux-gnu:
/usr/lib/i386-linux-gnu/mesa:
/usr/local/lib:
/lib/x86_64-linux-gnu:
/usr/lib/x86_64-linux-gnu:
/usr/lib/x86_64-linux-gnu/mesa-egl:
/usr/lib/x86_64-linux-gnu/mesa:
/lib:
/usr/lib:
/usr/lib/i386-linux-gnu/sse2: (hwcap: 0x0000000004000000)

echo $LD_LIBRARY_PATH 不打印任何内容。

最佳答案

-rpath 硬编码可执行文件或库中的r非时间库搜索路径。它不影响链接器搜索路径,因此您的应用程序与系统 Qt 库链接。您应该通过 -L 选项传递相同的路径:

gcc -Wl,-rpath,/home/<user>/Qt/5.10.0/gcc_64/lib -L/home/<user>/Qt/5.10.0/gcc_64/lib ...

这里是更多信息:

Why is -L needed when -rpath is used?

What's the difference between -rpath and -L?

关于c++ - Qt 应用程序中与 Qt 版本相关的运行时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50883220/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com