【发布时间】:2021-12-27 14:00:02
【问题描述】:
我正在测试一个基于 Qt 的 GUI 应用程序,它是在 Ubuntu 20.04 中使用 Qt creator 生成的。此应用程序使用一个需要 root 权限的库。然而,无法以 root 身份启动应用程序,因为它无法访问显示。
如果我以普通用户身份启动应用程序,我会在库中收到 modprobe 错误:
$ CGUTLGUI_Qt
qt.core.qobject.connect: QObject::connect: No such signal QSignalMapper::mapped(int) in ../src/cgosfunc/cgosgpio.cpp:242
qt.core.qobject.connect: QObject::connect: (receiver name: 'CgosGPIO')
modprobe: ERROR: could not insert 'cgosdrv': Operation not permitted
如果我以 root 身份启动应用程序,它无法连接到显示器:
$ sudo CGUTLGUI_Qt
No protocol specified
qt.qpa.xcb: could not connect to display :1
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vkkhrdisplay, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.
我只需要以一种或另一种方式运行程序,我不介意我不能修复这两个错误。以 root 身份启动 GUI 或以普通用户身份链接库都可以。
【问题讨论】: