以用户身份使用Qt Creator代码,但以root用户身份运行和调试 [英] Qt Creator code as a user but run and debug as root

查看:985
本文介绍了以用户身份使用Qt Creator代码,但以root用户身份运行和调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以以普通用户身份执行QtCreator,但可以以root用户身份运行和调试应用程序?

Would it be possible to execute QtCreator as a nornal user but run and debug an application as root?

这将很有用,即在基于 WiringPi 开发应用程序时,这有助于访问GPIO,但需要root才能有效启用对硬件的访问.

That would be useful i.e. while developing applications based on WiringPi, which facilitates the access to GPIO but requires root to effectively enable access to the hardware.

为了更加明确我的意图,我希望当我在QtCretor中按下Ctrl+R时,它将以root身份运行该应用程序.同样的调试思路,当我点击F5时,它将以root身份启动调试模式. QtCreator由普通用户运行时的所有情况.

To be more clear in my intentions, I would like that when I hit Ctrl+R in QtCretor, then it runs the app as root. And the same idea for debugging, when I hit F5 it starts debugging mode as root. All that while QtCreator is running by a normal user.

推荐答案

WiringPi不需要root访问权限.您只需要正确地为相关设备节点设置属性即可.确保您有/dev/gpiomem供WiringPi使用,并且用户可以写.它可以在4.1及更高版本的IIRC上使用.

WiringPi does not need root access. You need to set properties to the relevant device nodes properly, that's all. Make sure you have /dev/gpiomem available for use by WiringPi, writable by the user. It's available on 4.1 and newer kernels IIRC.

您的问题是X-Y问题的情况.是的,根访问权限可以避免设备节点属性错误的问题,但这根本不是一个正确的解决方案.不要以root用户身份运行您的应用程序.

Your question is a case of an X-Y problem. Yes, root access sidesteps the problem of wrong device node properties, but it's not a proper solution at all. Don't run your application as root.

这篇关于以用户身份使用Qt Creator代码,但以root用户身份运行和调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆