我想在非root用户的QNX 6.5 x86目标上运行使用QT 4.8.5开发的GUI应用程序。从root用户启动应用程序没有问题。但后来我尝试从非root用户运行它我得到了这个:
$ ./test_app -qws
QQnxScreen: gf_dev_attach() failed with error code 3
qnx: driver cannot connect
Abort (core dumped)
在这个用户的.profile中我有:
QWS_KEYBOARD=qnx
QWS_MOUSE_PROTO=qnx
QWS_DISPLAY=qnx
export QWS_KEYBOARD QWS_MOUSE_PROTO QWS_DISPLAY
export QT_PLUGIN_PATH=/opt/qt485/x86/plugins/
export QML_IMPORT_PATH=/opt/qt485/x86/imports/
export PATH=$PATH:/opt/qt485/bin/
export LD_LIBRARY_PATH=/opt/qt485/x86/lib/:$LD_LIBRARY_PATH
在相同的设置下,一切都能从根本上完美运作。
答案 0 :(得分:0)
尝试在显示组中包括非root用户,也许您会很幸运,并且视频驱动程序将不需要I / O特权。机会在io-display(http://www.qnx.com/developers/docs/6.5.0/topic/com.qnx.doc.neutrino_utilities/i/io-display.html)的说明中进行了描述。
如果不起作用,请在创建QApplication之后以root用户身份运行应用程序并将用户ID设置为非root用户:
#include <unistd.h> // for setgid and setuid
#include <grp.h> // for getgrnam
#include <pwd.h> // for getpwnam
#include <qapplication.h>
int main( int argc, char **argv )
{
const struct group* g = getgrnam("user");
const struct passwd* pw = getpwnam("user");
QApplication a( argc, argv );
setgid(g ? g->gr_gid : 0);
setuid(pw ? pw->pw_uid : 0);
return a.exec();
}