前言:
因项目需要,笔者最近一直在做国产系统的适配工作,中间遇到不少问题。本次笔者在安装系统间隙,记录下解决的上一个问题
已测试的笔记本:
- 华为国产笔记本 麒麟990处理器 + uos-desktop-20-professional-1060-arm64
- 华为国产笔记本 麒麟9000c处理器 + uos-desktop-20-professional-1060-arm64
问题1:
原装系统为uos-desktop-20-professional-1050-arm64,但在线安装软件时,好多软件无法正常安装。尝试强制安装后,笔记本瞬间变砖块。
解决方法:
为应对笔记本的抗议,笔者直接安装当前最新版本uos-desktop-20-professional-1060-arm64,软件在线安装问题解决
问题2:
使用自己编译的Qt库(Qt5.12.12),运行Qt程序,无法正常显示带GUI的widget程序
但使用源里安装的Qt库(Qt5.11.3),运行Qt程序,可以正常显示带GUI的widget程序
解决方法:
测试发现,显示界面使用的是wayland,而不是常用的xcb,记得需要编译qtwayland模块
若运行时,仍然无法显示,根据Qt官方文档,可以先修改下环境变量QT_WAYLAND_SHELL_INTEGRATION,以下是官方文档:
Some platforms, especially non-desktop ones, use a custom Wayland shell
extension. These are tailored to the specific embedded form factor better than
the generic wl_shell or xdg_shell extensions that target desktop systems.
Custom shell protocols are added through shell integration plugins.
Which shell integration to use is determined by the QT_WAYLAND_SHELL_INTEGRATION
environment variable. If no shell is specified, the default is to try shells in
the following order: xdg-shell, xdg-shell-v6, wl-shell and then ivi-shell.
Example Usage:
Starting the hellowindow example application (one of the examples for qtbase)
with ivi-shell integration:
QT_WAYLAND_SHELL_INTEGRATION=ivi-shell ./hellowindow -platform wayland
Available Shell Integrations:
* ivi-shell
* wl-shell (deprecated)
* xdg-shell
* xdg-shell-v5 (deprecated)
* xdg-shell-v6
网上大部分是设置QT_WAYLAND_SHELL_INTEGRATION=xdg-shell,但笔者测试时发现,设置为空也可以正常运行widget界面
问题3:
使用自己编译的Qt库(Qt5.12.12),运行Qt程序,无法正常显示带GUI的qml程序
解决方法:
使用Qt的xcb平台插件,可以正常显示,相关命令类似如下
./appname -platform xcb
不过要记得,要先编译对应平台插件,否则会提示找不到平台插件
问题4:
无法使用管理员权限运行带GUI的程序,但使用普通用户执行正常
若应该程序名是appname,无论是直接执行sudo ./appname,还是切换到root用户,再执行./appname,都无法正常显示界面,提示如下:
No protocol specified
No protocol specified
qt.qpa.xcb: could not connect to display :0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
解决方法
先执行 xhost +,若运行结果如下所示,说明生效了
然后再运行可执行文件,
sudo ./appname -platform xcb
后记:
做国产系统的适配工作,比较麻烦,特别是前几年及之前的机器,经常会遇到各种问题
如反应慢、缺库、源无法安装、库版本过低等,每个国产系统版本,都需要单独适配,而且经常没有资料可参考。
笔者建议,能升级到最新系统版本的,先进行系统升级,然后再做相关适配
当前的状况也在正逐渐改善,期待这几年的发展