Qt 5.13 之前对我来说都有奇怪的错误,所以我尝试将 Qt 的库版本更改为最新版本 (5.15)。我将 Qt 5.15 库安装到/home/myaccount/Qt/5.15.0/gcc_64/lib
,并进行了相应的设置/etc/ld.so.conf.d/Qt.5.15.0.conf
。以下是 的结果ldd usr/bin/konsole
:
/usr/bin/konsole: /lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.15' not found (required by /home/myaccount/Qt/5.15.0/gcc_64/lib/libQt5Widgets.so.5)
/usr/bin/konsole: /lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.15' not found (required by /home/myaccount/Qt/5.15.0/gcc_64/lib/libQt5Gui.so.5)
/usr/bin/konsole: /lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.15' not found (required by /home/myaccount/Qt/5.15.0/gcc_64/lib/libQt5PrintSupport.so.5)
/usr/bin/konsole: /lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.15' not found (required by /home/myaccount/Qt/5.15.0/gcc_64/lib/libQt5Xml.so.5)
/usr/bin/konsole: /lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.15' not found (required by /home/myaccount/Qt/5.15.0/gcc_64/lib/libQt5DBus.so.5)
/usr/bin/konsole: /lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.15' not found (required by /home/myaccount/Qt/5.15.0/gcc_64/lib/libQt5Network.so.5)
/usr/bin/konsole: /lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.15' not found (required by /home/myaccount/Qt/5.15.0/gcc_64/lib/libQt5X11Extras.so.5)
/usr/bin/konsole: /lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.15' not found (required by /home/myaccount/Qt/5.15.0/gcc_64/lib/libQt5Svg.so.5)
/usr/bin/konsole: /lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.15' not found (required by /home/myaccount/Qt/5.15.0/gcc_64/lib/libQt5TextToSpeech.so.5)
linux-vdso.so.1 (0x00007ffdc6592000)
libkdeinit5_konsole.so => /lib/x86_64-linux-gnu/libkdeinit5_konsole.so (0x00007f01a80dc000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f01a7eea000)
libkonsoleprivate.so.19 => /lib/x86_64-linux-gnu/libkonsoleprivate.so.19 (0x00007f01a7d79000)
...
libQt5Widgets.so.5 => /home/myaccount/Qt/5.15.0/gcc_64/lib/libQt5Widgets.so.5 (0x00007f01a6e95000)
libQt5Gui.so.5 => /home/myaccount/Qt/5.15.0/gcc_64/lib/libQt5Gui.so.5 (0x00007f01a6561000)
libQt5Core.so.5 => /lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007f01a6016000)
...
看起来程序(在本例中为 konsole)似乎仍然从 加载较旧的库/lib/x86_64-linux-gnu/
。奇怪的是,只有 libQt5Core 有此问题,而其他 Qt 库均已正确加载。
如果我执行类似操作,LD_LIBRARY_PATH="/home/myaccount/Qt/5.15.0/gcc_64/lib/" /usr/bin/konsole
它就可以正常工作。但是 Ubuntu 20.04 不喜欢从 .profile 设置 LD_LIBRARY_PATH,我正在寻找解决方法。有什么帮助吗?
答案1
这是 ldconfig 的一个错误/缺陷,此处已解决:https://bugs.freedesktop.org/show_bug.cgi?id=26663
简而言之,当给出 OS ABI 标签时,ldconfig 完全忽略库优先级。默认系统 qt 库的 OS ABI 标签为 3.17.0,而 5.15.0 库为 2.6.28。这会使默认系统 qt 库在 ldconfig 层次结构中始终位于 5.15.0 库之前。您可以使用 确认此行为ldconfig -p
。
我选择的解决方法是修补 5.15.0 库的 OS ABI 标签。在这种情况下,我使用了以下命令:
echo -en "\x04\x00\x00\x00\x10\x00\x00\x00\x01\x00\x00\x00\x47\x4e\x55\x00\x00\x00\x00\x00\x03\x00\x00\x00\x11\x00\x00\x00\x00\x00\x00\x00" > patch.txt
objcopy --update-section .note.ABI-tag=patch.txt /home/myaccount/Qt/5.15.0/gcc_64/libQt5Core.so.5.15.0 patched.so
然后替换libQt5Core.so.5.15.0
为patched.so
。我不认为这是一个值得推荐的解决方案,但它确实有效。确保创建备份。